Example #1
0
File: file.go Project: nhlfr/rkt
func (lb *FileBackend) GetImageInfo(dockerURL string) ([]string, *types.ParsedDockerURL, error) {
	parsedDockerURL, err := docker.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)
	if err != nil {
		return nil, nil, err
	}

	if len(ancestry) == 0 {
		ancestry, err = getAncestry(lb.file, appImageID)
		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
}
Example #2
0
func (rb *RepositoryBackend) GetImageInfo(url string) ([]string, *types.ParsedDockerURL, error) {
	dockerURL, err := docker.ParseDockerURL(url)
	if err != nil {
		return nil, nil, err
	}

	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)
	}
}
Example #3
0
func (lb *FileBackend) GetImageInfo(dockerURL string) ([]string, *types.ParsedDockerURL, error) {
	parsedDockerURL, err := docker.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
	}

	appImageID, parsedDockerURL, err := getImageID(lb.file, parsedDockerURL)
	if err != nil {
		return nil, nil, err
	}

	ancestry, err := getAncestry(lb.file, appImageID)
	if err != nil {
		return nil, nil, fmt.Errorf("error getting ancestry: %v", err)
	}

	return ancestry, parsedDockerURL, nil
}
Example #4
0
// ParseDockerURL takes a Docker URL and returns a ParsedDockerURL with its
// index URL, image name, and tag.
func ParseDockerURL(arg string) (*ParsedDockerURL, error) {
	p, err := docker.ParseDockerURL(arg)
	return (*ParsedDockerURL)(p), err
}