예제 #1
0
파일: client.go 프로젝트: Xmagicer/origin
// ImageByID returns the specified image within the named Docker image repository
func (c *connection) ImageByID(namespace, name, imageID string) (*Image, error) {
	if len(namespace) == 0 && imageapi.IsRegistryDockerHub(c.url.Host) {
		namespace = imageapi.DockerDefaultNamespace
	}
	if len(name) == 0 {
		return nil, fmt.Errorf("image name must be specified")
	}

	repo, err := c.getCachedRepository(fmt.Sprintf("%s/%s", namespace, name))
	if err != nil {
		return nil, err
	}

	return repo.getImage(c, imageID, "")
}
예제 #2
0
파일: client.go 프로젝트: Xmagicer/origin
// ImageByTag returns the specified image within the named Docker image repository
func (c *connection) ImageByTag(namespace, name, tag string) (*Image, error) {
	if len(namespace) == 0 && imageapi.IsRegistryDockerHub(c.url.Host) {
		namespace = imageapi.DockerDefaultNamespace
	}
	if len(name) == 0 {
		return nil, fmt.Errorf("image name must be specified")
	}
	searchTag := tag
	if len(searchTag) == 0 {
		searchTag = imageapi.DefaultImageTag
	}

	repo, err := c.getCachedRepository(fmt.Sprintf("%s/%s", namespace, name))
	if err != nil {
		return nil, err
	}

	return repo.getTaggedImage(c, searchTag, tag)
}