fix: runtime caching for catalogue generation
This commit is contained in:
parent
9f70a69bbf
commit
3f35510507
@ -410,6 +410,7 @@ func GetRecipeVersions(recipeName string) (RecipeVersions, error) {
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
|
||||
queryCache := make(map[reference.Named]string)
|
||||
versionMeta := make(map[string]ServiceMeta)
|
||||
for _, service := range recipe.Config.Services {
|
||||
|
||||
@ -432,12 +433,21 @@ func GetRecipeVersions(recipeName string) (RecipeVersions, error) {
|
||||
continue
|
||||
}
|
||||
|
||||
logrus.Debugf("looking up image: %s from %s", img, path)
|
||||
|
||||
digest, err := client.GetTagDigest(cl, img)
|
||||
if err != nil {
|
||||
logrus.Warn(err)
|
||||
continue
|
||||
var exists bool
|
||||
var digest string
|
||||
if digest, exists = queryCache[img]; !exists {
|
||||
logrus.Debugf("looking up image: %s from %s", img, path)
|
||||
var err error
|
||||
digest, err = client.GetTagDigest(cl, img)
|
||||
if err != nil {
|
||||
logrus.Warn(err)
|
||||
continue
|
||||
}
|
||||
logrus.Debugf("queried for image: %s, tag: %s, digest: %s", path, tag, digest)
|
||||
queryCache[img] = digest
|
||||
logrus.Debugf("cached image: %s, tag: %s, digest: %s", path, tag, digest)
|
||||
} else {
|
||||
logrus.Debugf("reading image: %s, tag: %s, digest: %s from cache", path, tag, digest)
|
||||
}
|
||||
|
||||
versionMeta[service.Name] = ServiceMeta{
|
||||
@ -445,8 +455,6 @@ func GetRecipeVersions(recipeName string) (RecipeVersions, error) {
|
||||
Image: path,
|
||||
Tag: img.(reference.NamedTagged).Tag(),
|
||||
}
|
||||
|
||||
logrus.Debugf("collecting digest: %s, image: %s, tag: %s", digest, path, tag)
|
||||
}
|
||||
|
||||
versions = append(versions, map[string]map[string]ServiceMeta{tag: versionMeta})
|
||||
|
Loading…
Reference in New Issue
Block a user