forked from toolshed/abra
		
	fix: runtime caching for catalogue generation
This commit is contained in:
		@ -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,21 +433,28 @@ func GetRecipeVersions(recipeName string) (RecipeVersions, error) {
 | 
			
		||||
				continue
 | 
			
		||||
			}
 | 
			
		||||
 | 
			
		||||
			var exists bool
 | 
			
		||||
			var digest string
 | 
			
		||||
			if digest, exists = queryCache[img]; !exists {
 | 
			
		||||
				logrus.Debugf("looking up image: %s from %s", img, path)
 | 
			
		||||
 | 
			
		||||
			digest, err := client.GetTagDigest(cl, img)
 | 
			
		||||
				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{
 | 
			
		||||
				Digest: digest,
 | 
			
		||||
				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})
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user