func (lb *FileBackend) GetImageInfo(dockerURL string) ([]string, *common.ParsedDockerURL, error) { parsedDockerURL, err := common.ParseDockerURL(dockerURL) if err != nil { // a missing Docker URL could mean that the file only contains one // image, so we ignore the error here, we'll handle it in getImageID } var ancestry []string // default file name is the tar name stripped name := strings.Split(filepath.Base(lb.file.Name()), ".")[0] appImageID, ancestry, parsedDockerURL, err := getImageID(lb.file, parsedDockerURL, name, lb.debug) if err != nil { return nil, nil, err } if len(ancestry) == 0 { ancestry, err = getAncestry(lb.file, appImageID, lb.debug) if err != nil { return nil, nil, fmt.Errorf("error getting ancestry: %v", err) } } else { // for oci the first image is the config ancestry = append([]string{appImageID}, ancestry...) } return ancestry, parsedDockerURL, nil }
func (rb *RepositoryBackend) GetImageInfo(url string) ([]string, *types.ParsedDockerURL, error) { dockerURL := common.ParseDockerURL(url) var supportsV2, ok bool var URLSchema string if supportsV2, ok = rb.hostsV2Support[dockerURL.IndexURL]; !ok { var err error URLSchema, supportsV2, err = rb.supportsRegistry(dockerURL.IndexURL, registryV2) if err != nil { return nil, nil, err } rb.schema = URLSchema + "://" rb.hostsV2Support[dockerURL.IndexURL] = supportsV2 } if supportsV2 { return rb.getImageInfoV2(dockerURL) } else { URLSchema, supportsV1, err := rb.supportsRegistry(dockerURL.IndexURL, registryV1) if err != nil { return nil, nil, err } if !supportsV1 { return nil, nil, fmt.Errorf("registry doesn't support API v2 nor v1") } rb.schema = URLSchema + "://" return rb.getImageInfoV1(dockerURL) } }
// GetHash uses docker2aci to download the image and convert it to // ACI, then stores it in the store and returns the hash. func (f *dockerFetcher) GetHash(u *url.URL) (string, error) { ensureLogger(f.Debug) dockerURL, err := d2acommon.ParseDockerURL(path.Join(u.Host, u.Path)) if err != nil { return "", fmt.Errorf(`invalid docker URL %q; expected syntax is "docker://[REGISTRY_HOST[:REGISTRY_PORT]/]IMAGE_NAME[:TAG]"`, u) } latest := dockerURL.Tag == "latest" return f.fetchImageFrom(u, latest) }
func (lb *FileBackend) GetImageInfo(dockerURL string) ([]string, *types.ParsedDockerURL, error) { parsedDockerURL := common.ParseDockerURL(dockerURL) appImageID, parsedDockerURL, err := getImageID(lb.file, parsedDockerURL) if err != nil { return nil, nil, fmt.Errorf("error getting ImageID: %v", err) } ancestry, err := getAncestry(lb.file, appImageID) if err != nil { return nil, nil, fmt.Errorf("error getting ancestry: %v", err) } return ancestry, parsedDockerURL, nil }
func (rb *RepositoryBackend) GetImageInfo(url string) ([]string, *types.ParsedDockerURL, error) { dockerURL := common.ParseDockerURL(url) var supportsV2, ok bool if supportsV2, ok = rb.hostsV2Support[dockerURL.IndexURL]; !ok { var err error supportsV2, err = rb.supportsV2(dockerURL.IndexURL) if err != nil { return nil, nil, err } rb.hostsV2Support[dockerURL.IndexURL] = supportsV2 } if supportsV2 { return rb.getImageInfoV2(dockerURL) } else { return rb.getImageInfoV1(dockerURL) } }
func (rb *RepositoryBackend) GetImageInfo(url string) ([]string, *common.ParsedDockerURL, error) { dockerURL, err := common.ParseDockerURL(url) if err != nil { return nil, nil, err } var supportsV2, supportsV1, ok bool var URLSchema string if supportsV2, ok = rb.hostsV2Support[dockerURL.IndexURL]; !ok { var err error URLSchema, supportsV2, err = rb.supportsRegistry(dockerURL.IndexURL, registryV2) if err != nil { return nil, nil, err } rb.schema = URLSchema + "://" rb.hostsV2Support[dockerURL.IndexURL] = supportsV2 } // try v2 if supportsV2 { layers, dockerURL, err := rb.getImageInfoV2(dockerURL) if !isErrHTTP404(err) { return layers, dockerURL, err } // fallback on 404 failure rb.hostsV1fallback = true } URLSchema, supportsV1, err = rb.supportsRegistry(dockerURL.IndexURL, registryV1) if err != nil { return nil, nil, err } if !supportsV1 && rb.hostsV1fallback { return nil, nil, fmt.Errorf("attempted fallback to API v1 but not supported") } if !supportsV1 && !supportsV2 { return nil, nil, fmt.Errorf("registry doesn't support API v2 nor v1") } rb.schema = URLSchema + "://" // try v1, hard fail on failure return rb.getImageInfoV1(dockerURL) }
// NewDocker creates a new docker distribution from the provided distribution uri string func NewDocker(u *url.URL) (Distribution, error) { dp, err := parseCIMD(u) if err != nil { return nil, fmt.Errorf("cannot parse URI: %q: %v", u.String(), err) } if dp.Type != TypeDocker { return nil, fmt.Errorf("wrong distribution type: %q", dp.Type) } parsed, err := d2acommon.ParseDockerURL(dp.Data) if err != nil { return nil, fmt.Errorf("bad docker URL %q: %v", dp.Data, err) } return &Docker{ url: dp.Data, parsedURL: parsed, simple: SimpleDockerRef(parsed), full: FullDockerRef(parsed), }, nil }
func (rb *RepositoryBackend) GetImageInfo(url string) ([]string, *types.ParsedDockerURL, error) { dockerURL := common.ParseDockerURL(url) repoData, err := rb.getRepoData(dockerURL.IndexURL, dockerURL.ImageName) if err != nil { return nil, nil, fmt.Errorf("error getting repository data: %v", err) } // TODO(iaguis) check more endpoints appImageID, err := getImageIDFromTag(repoData.Endpoints[0], dockerURL.ImageName, dockerURL.Tag, repoData) if err != nil { return nil, nil, fmt.Errorf("error getting ImageID from tag %s: %v", dockerURL.Tag, err) } ancestry, err := getAncestry(appImageID, repoData.Endpoints[0], repoData) if err != nil { return nil, nil, err } rb.repoData = repoData return ancestry, dockerURL, nil }
// GetHash uses docker2aci to download the image and convert it to // ACI, then stores it in the store and returns the hash. func (f *dockerFetcher) GetHash(u *url.URL) (string, error) { ensureLogger(f.Debug) dockerURL := d2acommon.ParseDockerURL(path.Join(u.Host, u.Path)) latest := dockerURL.Tag == "latest" return f.fetchImageFrom(u, latest) }