diff --git a/cmd/skopeo/inspect.go b/cmd/skopeo/inspect.go index 880bda91..790a2017 100644 --- a/cmd/skopeo/inspect.go +++ b/cmd/skopeo/inspect.go @@ -3,11 +3,26 @@ package main import ( "encoding/json" "fmt" + "time" "github.com/Sirupsen/logrus" "github.com/codegangsta/cli" ) +// inspectOutput is the output format of (skopeo inspect), primarily so that we can format it with a simple json.MarshalIndent. +type inspectOutput struct { + Name string + Tag string + Digest string + RepoTags []string + Created time.Time + DockerVersion string + Labels map[string]string + Architecture string + Os string + Layers []string +} + var inspectCmd = cli.Command{ Name: "inspect", Usage: "inspect images on a registry", @@ -34,7 +49,19 @@ var inspectCmd = cli.Command{ if err != nil { logrus.Fatal(err) } - out, err := json.MarshalIndent(imgInspect, "", " ") + outputData := inspectOutput{ + Name: imgInspect.Name, + Tag: imgInspect.Tag, + Digest: imgInspect.Digest, + RepoTags: imgInspect.RepoTags, + Created: imgInspect.Created, + DockerVersion: imgInspect.DockerVersion, + Labels: imgInspect.Labels, + Architecture: imgInspect.Architecture, + Os: imgInspect.Os, + Layers: imgInspect.Layers, + } + out, err := json.MarshalIndent(outputData, "", " ") if err != nil { logrus.Fatal(err) } diff --git a/docker/docker_image.go b/docker/docker_image.go index a708ddec..97fad461 100644 --- a/docker/docker_image.go +++ b/docker/docker_image.go @@ -62,7 +62,7 @@ func (i *dockerImage) Signatures() ([][]byte, error) { return i.cachedSignatures, nil } -func (i *dockerImage) Inspect() (types.ImageManifest, error) { +func (i *dockerImage) Inspect() (*types.DockerImageManifest, error) { // TODO(runcom): unused version param for now, default to docker v2-1 m, err := i.getSchema1Manifest() if err != nil { @@ -122,7 +122,7 @@ type v1Image struct { OS string `json:"os,omitempty"` } -func makeImageManifest(name string, m *manifestSchema1, dgst string, tagList []string) (types.ImageManifest, error) { +func makeImageManifest(name string, m *manifestSchema1, dgst string, tagList []string) (*types.DockerImageManifest, error) { v1 := &v1Image{} if err := json.Unmarshal([]byte(m.History[0].V1Compatibility), v1); err != nil { return nil, err diff --git a/types/types.go b/types/types.go index 1f1a4626..4bc37138 100644 --- a/types/types.go +++ b/types/types.go @@ -62,16 +62,10 @@ type Image interface { // Signatures is like ImageSource.GetSignatures, but the result is cached; it is OK to call this however often you need. Signatures() ([][]byte, error) Layers(layers ...string) error // configure download directory? Call it DownloadLayers? - Inspect() (ImageManifest, error) + Inspect() (*DockerImageManifest, error) DockerTar() ([]byte, error) // ??? also, configure output directory } -// ImageManifest is the interesting subset of metadata about an Image. -// TODO(runcom) -type ImageManifest interface { - String() string -} - // DockerImageManifest is a set of metadata describing Docker images and their manifest.json files. // Note that this is not exactly manifest.json, e.g. some fields have been added. type DockerImageManifest struct {