Пример #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 errwrap.Wrap(fmt.Errorf("failed to get dependencies for image ID %q", hash), err)
	}
	for _, d := range dependencies {
		imgName := d.ImageName.String()
		app, err := discovery.NewApp(imgName, d.Labels.ToMap())
		if err != nil {
			return errwrap.Wrap(fmt.Errorf("one of image ID's %q dependencies (image %q) is invalid", hash, imgName), err)
		}
		appStr := app.String()
		if _, ok := seen[appStr]; ok {
			continue
		}
		imgsl.PushBack(app.String())
		seen[appStr] = struct{}{}
	}
	return nil
}
Пример #2
0
func (r Registry) discoverEndpoint(imageName types.ACIdentifier, labels types.Labels) (*discovery.ACIEndpoint, error) {
	labelmap := make(map[types.ACIdentifier]string)
	for _, label := range labels {
		labelmap[label.Name] = label.Value
	}

	app, err := discovery.NewApp(string(imageName), labelmap)
	if err != nil {
		return nil, err
	}
	if _, ok := app.Labels["arch"]; !ok {
		app.Labels["arch"] = runtime.GOARCH
	}
	if _, ok := app.Labels["os"]; !ok {
		app.Labels["os"] = runtime.GOOS
	}

	insecure := discovery.InsecureNone
	if r.Insecure {
		insecure = discovery.InsecureHTTP
	}

	acis, attempts, err := discovery.DiscoverACIEndpoints(*app, nil, insecure)
	if err != nil {
		return nil, err
	}
	if r.Debug {
		for _, a := range attempts {
			fmt.Fprintf(os.Stderr, "meta tag not found on %s: %v\n",
				a.Prefix, a.Error)
		}
	}
	if len(acis) == 0 {
		return nil, fmt.Errorf("no endpoints discovered to download %s",
			imageName)
	}

	return &acis[0], nil
}
Пример #3
0
func (f *Fetcher) addImageDeps(hash string, imgsl *list.List, seen map[string]dist.Distribution) error {
	dependencies, err := f.getImageDeps(hash)
	if err != nil {
		return errwrap.Wrap(fmt.Errorf("failed to get dependencies for image ID %q", hash), err)
	}
	for _, d := range dependencies {
		imgName := d.ImageName.String()
		app, err := discovery.NewApp(imgName, d.Labels.ToMap())
		if err != nil {
			return errwrap.Wrap(fmt.Errorf("one of image ID's %q dependencies (image %q) is invalid", hash, imgName), err)
		}
		d := dist.NewAppcFromApp(app)
		// To really catch already seen deps the saved string must be a
		// reproducible string keeping the labels order
		for _, sd := range seen {
			if d.Equals(sd) {
				continue
			}
		}
		imgsl.PushBack(d)
		seen[d.CIMD().String()] = d
	}
	return nil
}