Signed-off-by: Jess Frazelle <acidburn@google.com>
This commit is contained in:
Jess Frazelle 2017-03-04 22:17:50 -08:00
parent 8068daf683
commit 2bda5d50d7
No known key found for this signature in database
GPG key ID: 18F3685C0022BFF3

View file

@ -189,13 +189,13 @@ func createStaticIndex(r *registry.Registry, staticDir, clairURI string) error {
logrus.Info("fetching tags") logrus.Info("fetching tags")
var repos []repository var repos []repository
for _, repo := range repoList { for i, repo := range repoList {
// get the tags // get the tags
tags, err := r.Tags(repo) tags, err := r.Tags(repo)
if err != nil { if err != nil {
return fmt.Errorf("getting tags for %s failed: %v", repo, err) return fmt.Errorf("getting tags for %s failed: %v", repo, err)
} }
for _, tag := range tags { for j, tag := range tags {
// get the manifest // get the manifest
manifest, err := r.Manifest(repo, tag) manifest, err := r.Manifest(repo, tag)
@ -231,10 +231,10 @@ func createStaticIndex(r *registry.Registry, staticDir, clairURI string) error {
if clairURI != "" { if clairURI != "" {
wg.Add(1) wg.Add(1)
go func(repo, tag string) { go func(repo, tag string, i, j int) {
defer wg.Done() defer wg.Done()
throttle := time.Tick(time.Duration(1e6/int(3)) * time.Microsecond) throttle := time.Tick(time.Duration(time.Duration(i*j) * time.Second))
<-throttle <-throttle
logrus.Infof("creating vulns.txt for %s:%s", repo, tag) logrus.Infof("creating vulns.txt for %s:%s", repo, tag)
@ -243,7 +243,7 @@ func createStaticIndex(r *registry.Registry, staticDir, clairURI string) error {
// return fmt.Errorf("creating vuln static page for %s:%s failed: %v", repo, tag, err) // 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) logrus.Warnf("creating vuln static page for %s:%s failed: %v", repo, tag, err)
} }
}(repo, tag) }(repo, tag, i, j)
newrepo.VulnURI = filepath.Join(repo, tag, "vulns.txt") newrepo.VulnURI = filepath.Join(repo, tag, "vulns.txt")
} }