mirror of
https://github.com/genuinetools/reg.git
synced 2024-06-30 11:04:16 -04:00
use a go func
Signed-off-by: Jess Frazelle <acidburn@google.com>
This commit is contained in:
parent
245b72c0ce
commit
ce8d46aa0c
|
@ -10,6 +10,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/Sirupsen/logrus"
|
"github.com/Sirupsen/logrus"
|
||||||
|
@ -31,6 +32,7 @@ const (
|
||||||
|
|
||||||
var (
|
var (
|
||||||
updating = false
|
updating = false
|
||||||
|
wg sync.WaitGroup
|
||||||
)
|
)
|
||||||
|
|
||||||
// preload initializes any global options and configuration
|
// preload initializes any global options and configuration
|
||||||
|
@ -128,6 +130,7 @@ func main() {
|
||||||
if !updating {
|
if !updating {
|
||||||
if err := createStaticIndex(r, staticDir, c.GlobalString("clair")); err != nil {
|
if err := createStaticIndex(r, staticDir, c.GlobalString("clair")); err != nil {
|
||||||
logrus.Warnf("creating static index failed: %v", err)
|
logrus.Warnf("creating static index failed: %v", err)
|
||||||
|
wg.Wait()
|
||||||
updating = false
|
updating = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -293,11 +296,15 @@ func createStaticIndex(r *registry.Registry, staticDir, clairURI string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
if clairURI != "" {
|
if clairURI != "" {
|
||||||
logrus.Infof("creating vulns.txt for %s:%s", repo, tag)
|
wg.Add(1)
|
||||||
if err := createVulnStaticPage(r, staticDir, clairURI, repo, tag); err != nil {
|
go func(repo, tag string) {
|
||||||
//return fmt.Errorf("creating vuln static page for %s:%s failed: %v", repo, tag, err)
|
defer wg.Done()
|
||||||
logrus.Warnf("creating vuln static page for %s:%s failed: %v", repo, tag, err)
|
logrus.Infof("creating vulns.txt for %s:%s", repo, tag)
|
||||||
}
|
if err := createVulnStaticPage(r, staticDir, clairURI, repo, tag); err != nil {
|
||||||
|
// return fmt.Errorf("creating vuln static page for %s:%s failed: %v", repo, tag, err)
|
||||||
|
logrus.Warnf("creating vuln static page for %s:%s failed: %v", repo, tag, err)
|
||||||
|
}
|
||||||
|
}(repo, tag)
|
||||||
newrepo.VulnURI = filepath.Join(repo, tag, "vulns.txt")
|
newrepo.VulnURI = filepath.Join(repo, tag, "vulns.txt")
|
||||||
}
|
}
|
||||||
repos = append(repos, newrepo)
|
repos = append(repos, newrepo)
|
||||||
|
|
Loading…
Reference in a new issue