Пример #1
0
func (f *fetcher) addImageDeps(hash string, imgsl *list.List, seen map[string]struct{}) error {
	dependencies, err := f.getImageDeps(hash)
	if err != nil {
		return err
	}
	for _, d := range dependencies {
		app, err := discovery.NewApp(d.ImageName.String(), d.Labels.ToMap())
		if err != nil {
			return err
		}
		imgsl.PushBack(app.String())
		if _, ok := seen[app.String()]; ok {
			return fmt.Errorf("dependency %s specified multiple times in the dependency tree for imageID: %s", app.String(), hash)
		}
		seen[app.String()] = struct{}{}
	}
	return nil
}
Пример #2
0
func (f *Fetcher) addImageDeps(hash string, imgsl *list.List, seen map[string]struct{}) error {
	dependencies, err := f.getImageDeps(hash)
	if err != nil {
		return fmt.Errorf("failed to get dependencies for image ID %q: %v", hash, err)
	}
	for _, d := range dependencies {
		imgName := d.ImageName.String()
		app, err := discovery.NewApp(imgName, d.Labels.ToMap())
		if err != nil {
			return fmt.Errorf("one of image ID's %q dependencies (image %q) is invalid: %v", hash, imgName, err)
		}
		appStr := app.String()
		if _, ok := seen[appStr]; ok {
			continue
		}
		imgsl.PushBack(app.String())
		seen[appStr] = struct{}{}
	}
	return nil
}