mirror of
https://github.com/containers/skopeo.git
synced 2025-06-28 15:47:34 +00:00
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:
parent
60e8d63712
commit
9766f72760
@ -54,11 +54,15 @@ var inspectCmd = cli.Command{
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
logrus.Fatalf("Error computing manifest digest: %s", err.Error())
|
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{
|
outputData := inspectOutput{
|
||||||
Name: imgInspect.Name,
|
Name: imgInspect.Name,
|
||||||
Tag: imgInspect.Tag,
|
Tag: imgInspect.Tag,
|
||||||
Digest: manifestDigest,
|
Digest: manifestDigest,
|
||||||
RepoTags: imgInspect.RepoTags,
|
RepoTags: repoTags,
|
||||||
Created: imgInspect.Created,
|
Created: imgInspect.Created,
|
||||||
DockerVersion: imgInspect.DockerVersion,
|
DockerVersion: imgInspect.DockerVersion,
|
||||||
Labels: imgInspect.Labels,
|
Labels: imgInspect.Labels,
|
||||||
|
@ -75,18 +75,15 @@ func (i *dockerImage) Inspect() (*types.DockerImageManifest, error) {
|
|||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("error retrivieng manifest schema1")
|
return nil, fmt.Errorf("error retrivieng manifest schema1")
|
||||||
}
|
}
|
||||||
tags, err := i.getTags()
|
imgManifest, err := makeImageManifest(i.src.ref.FullName(), ms1)
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
imgManifest, err := makeImageManifest(i.src.ref.FullName(), ms1, tags)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
return imgManifest, nil
|
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.
|
// FIXME? Breaking the abstraction.
|
||||||
url := fmt.Sprintf(tagsURL, i.src.ref.RemoteName())
|
url := fmt.Sprintf(tagsURL, i.src.ref.RemoteName())
|
||||||
res, err := i.src.c.makeRequest("GET", url, nil, nil)
|
res, err := i.src.c.makeRequest("GET", url, nil, nil)
|
||||||
@ -125,7 +122,7 @@ type v1Image struct {
|
|||||||
OS string `json:"os,omitempty"`
|
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{}
|
v1 := &v1Image{}
|
||||||
if err := json.Unmarshal([]byte(m.History[0].V1Compatibility), v1); err != nil {
|
if err := json.Unmarshal([]byte(m.History[0].V1Compatibility), v1); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -133,7 +130,6 @@ func makeImageManifest(name string, m *manifestSchema1, tagList []string) (*type
|
|||||||
return &types.DockerImageManifest{
|
return &types.DockerImageManifest{
|
||||||
Name: name,
|
Name: name,
|
||||||
Tag: m.Tag,
|
Tag: m.Tag,
|
||||||
RepoTags: tagList,
|
|
||||||
DockerVersion: v1.DockerVersion,
|
DockerVersion: v1.DockerVersion,
|
||||||
Created: v1.Created,
|
Created: v1.Created,
|
||||||
Labels: v1.Config.Labels,
|
Labels: v1.Config.Labels,
|
||||||
|
@ -64,6 +64,8 @@ type Image interface {
|
|||||||
Layers(layers ...string) error // configure download directory? Call it DownloadLayers?
|
Layers(layers ...string) error // configure download directory? Call it DownloadLayers?
|
||||||
Inspect() (*DockerImageManifest, error)
|
Inspect() (*DockerImageManifest, error)
|
||||||
DockerTar() ([]byte, error) // ??? also, configure output directory
|
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.
|
// DockerImageManifest is a set of metadata describing Docker images and their manifest.json files.
|
||||||
@ -71,7 +73,6 @@ type Image interface {
|
|||||||
type DockerImageManifest struct {
|
type DockerImageManifest struct {
|
||||||
Name string
|
Name string
|
||||||
Tag string
|
Tag string
|
||||||
RepoTags []string
|
|
||||||
Created time.Time
|
Created time.Time
|
||||||
DockerVersion string
|
DockerVersion string
|
||||||
Labels map[string]string
|
Labels map[string]string
|
||||||
|
Loading…
Reference in New Issue
Block a user