Move listing of repository tags from Image.Manifest to a separate Image.GetRepositoryTags

This does not change behavior.

Splits listing of repository tags, which is not a property of an image,
from the image.Manifest gathering of information about an image.
This commit is contained in:
Miloslav Trmač 2016-05-16 17:50:42 +02:00
parent 60e8d63712
commit 9766f72760
3 changed files with 11 additions and 10 deletions

View File

@ -54,11 +54,15 @@ var inspectCmd = cli.Command{
if err != nil {
logrus.Fatalf("Error computing manifest digest: %s", err.Error())
}
repoTags, err := img.GetRepositoryTags()
if err != nil {
logrus.Fatalf("Error determining repository tags: %s", err.Error())
}
outputData := inspectOutput{
Name: imgInspect.Name,
Tag: imgInspect.Tag,
Digest: manifestDigest,
RepoTags: imgInspect.RepoTags,
RepoTags: repoTags,
Created: imgInspect.Created,
DockerVersion: imgInspect.DockerVersion,
Labels: imgInspect.Labels,

View File

@ -75,18 +75,15 @@ func (i *dockerImage) Inspect() (*types.DockerImageManifest, error) {
if !ok {
return nil, fmt.Errorf("error retrivieng manifest schema1")
}
tags, err := i.getTags()
if err != nil {
return nil, err
}
imgManifest, err := makeImageManifest(i.src.ref.FullName(), ms1, tags)
imgManifest, err := makeImageManifest(i.src.ref.FullName(), ms1)
if err != nil {
return nil, err
}
return imgManifest, nil
}
func (i *dockerImage) getTags() ([]string, error) {
// GetRepositoryTags list all tags available in the repository. Note that this has no connection with the tag(s) used for this specific image, if any.
func (i *dockerImage) GetRepositoryTags() ([]string, error) {
// FIXME? Breaking the abstraction.
url := fmt.Sprintf(tagsURL, i.src.ref.RemoteName())
res, err := i.src.c.makeRequest("GET", url, nil, nil)
@ -125,7 +122,7 @@ type v1Image struct {
OS string `json:"os,omitempty"`
}
func makeImageManifest(name string, m *manifestSchema1, tagList []string) (*types.DockerImageManifest, error) {
func makeImageManifest(name string, m *manifestSchema1) (*types.DockerImageManifest, error) {
v1 := &v1Image{}
if err := json.Unmarshal([]byte(m.History[0].V1Compatibility), v1); err != nil {
return nil, err
@ -133,7 +130,6 @@ func makeImageManifest(name string, m *manifestSchema1, tagList []string) (*type
return &types.DockerImageManifest{
Name: name,
Tag: m.Tag,
RepoTags: tagList,
DockerVersion: v1.DockerVersion,
Created: v1.Created,
Labels: v1.Config.Labels,

View File

@ -64,6 +64,8 @@ type Image interface {
Layers(layers ...string) error // configure download directory? Call it DownloadLayers?
Inspect() (*DockerImageManifest, error)
DockerTar() ([]byte, error) // ??? also, configure output directory
// GetRepositoryTags list all tags available in the repository. Note that this has no connection with the tag(s) used for this specific image, if any.
GetRepositoryTags() ([]string, error)
}
// DockerImageManifest is a set of metadata describing Docker images and their manifest.json files.
@ -71,7 +73,6 @@ type Image interface {
type DockerImageManifest struct {
Name string
Tag string
RepoTags []string
Created time.Time
DockerVersion string
Labels map[string]string