From dc7a05ebf913ce9c92dd681f4bf9c01871a1ea5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20Trma=C4=8D?= Date: Mon, 16 May 2016 20:06:12 +0200 Subject: [PATCH 1/3] Rename types.Image.Manifest to types.Image.Inspect Does not change behavior. This better expresses the purpose of this method (it is working with more, currently much more, than the manifest), and frees up the Manifest method name for a simple getter of the raw blob. --- cmd/skopeo/inspect.go | 2 +- docker/docker_image.go | 2 +- types/types.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/skopeo/inspect.go b/cmd/skopeo/inspect.go index 6b7035fb..e77cfa89 100644 --- a/cmd/skopeo/inspect.go +++ b/cmd/skopeo/inspect.go @@ -30,7 +30,7 @@ var inspectCmd = cli.Command{ fmt.Println(string(b)) return } - imgInspect, err := img.Manifest() + imgInspect, err := img.Inspect() if err != nil { logrus.Fatal(err) } diff --git a/docker/docker_image.go b/docker/docker_image.go index bd2bfe39..9b9245b6 100644 --- a/docker/docker_image.go +++ b/docker/docker_image.go @@ -62,7 +62,7 @@ func (i *dockerImage) GetSignatures() ([][]byte, error) { return i.cachedSignatures, nil } -func (i *dockerImage) Manifest() (types.ImageManifest, error) { +func (i *dockerImage) Inspect() (types.ImageManifest, error) { // TODO(runcom): unused version param for now, default to docker v2-1 m, err := i.getSchema1Manifest() if err != nil { diff --git a/types/types.go b/types/types.go index 3c579f93..f88c6c14 100644 --- a/types/types.go +++ b/types/types.go @@ -60,7 +60,7 @@ type Image interface { // GetSignatures is like ImageSource.GetSignatures, but the result is cached; it is OK to call this however often you need. GetSignatures() ([][]byte, error) Layers(layers ...string) error // configure download directory? Call it DownloadLayers? - Manifest() (ImageManifest, error) + Inspect() (ImageManifest, error) DockerTar() ([]byte, error) // ??? also, configure output directory } From 119609b871bd9bd463b62acdba1c49108a893c06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20Trma=C4=8D?= Date: Mon, 16 May 2016 20:29:52 +0200 Subject: [PATCH 2/3] Drop the Get prefix from types.Image.GetManifest and GetSignatures Keeps the Get prefix on the equivalent methods on types.ImageSource, to hint that they may be slow. --- cmd/skopeo/inspect.go | 2 +- docker/docker_image.go | 10 +++++----- types/types.go | 10 ++++++---- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/cmd/skopeo/inspect.go b/cmd/skopeo/inspect.go index e77cfa89..880bda91 100644 --- a/cmd/skopeo/inspect.go +++ b/cmd/skopeo/inspect.go @@ -23,7 +23,7 @@ var inspectCmd = cli.Command{ logrus.Fatal(err) } if c.Bool("raw") { - b, err := img.GetManifest() + b, err := img.Manifest() if err != nil { logrus.Fatal(err) } diff --git a/docker/docker_image.go b/docker/docker_image.go index 9b9245b6..c9ab31b8 100644 --- a/docker/docker_image.go +++ b/docker/docker_image.go @@ -22,7 +22,7 @@ type dockerImage struct { src *dockerImageSource digest string rawManifest []byte - cachedSignatures [][]byte // Private cache for GetSignatures; nil if not yet known. + cachedSignatures [][]byte // Private cache for Signatures(); nil if not yet known. } // NewDockerImage returns a new Image interface type after setting up @@ -42,16 +42,16 @@ func (i *dockerImage) GetIntendedDockerReference() string { return i.src.GetIntendedDockerReference() } -// GetManifest is like ImageSource.GetManifest, but the result is cached; it is OK to call this however often you need. -func (i *dockerImage) GetManifest() ([]byte, error) { +// Manifest is like ImageSource.GetManifest, but the result is cached; it is OK to call this however often you need. +func (i *dockerImage) Manifest() ([]byte, error) { if err := i.retrieveRawManifest(); err != nil { return nil, err } return i.rawManifest, nil } -// GetSignatures is like ImageSource.GetSignatures, but the result is cached; it is OK to call this however often you need. -func (i *dockerImage) GetSignatures() ([][]byte, error) { +// Signatures is like ImageSource.GetSignatures, but the result is cached; it is OK to call this however often you need. +func (i *dockerImage) Signatures() ([][]byte, error) { if i.cachedSignatures == nil { sigs, err := i.src.GetSignatures() if err != nil { diff --git a/types/types.go b/types/types.go index f88c6c14..a8f0e82c 100644 --- a/types/types.go +++ b/types/types.go @@ -34,8 +34,10 @@ type ImageSource interface { // (not as the image itself, or its underlying storage, claims). This can be used e.g. to determine which public keys are trusted for this image. // May be "" if unknown. GetIntendedDockerReference() string + // GetManifest returns the image's manifest. It may use a remote (= slow) service. GetManifest() (manifest []byte, unverifiedCanonicalDigest string, err error) GetLayer(digest string) (io.ReadCloser, error) + // GetSignatures returns the image's signatures. It may use a remote (= slow) service. GetSignatures() ([][]byte, error) } @@ -55,10 +57,10 @@ type Image interface { // (not as the image itself, or its underlying storage, claims). This can be used e.g. to determine which public keys are trusted for this image. // May be "" if unknown. GetIntendedDockerReference() string - // GetManifest is like ImageSource.GetManifest, but the result is cached; it is OK to call this however often you need. - GetManifest() ([]byte, error) - // GetSignatures is like ImageSource.GetSignatures, but the result is cached; it is OK to call this however often you need. - GetSignatures() ([][]byte, error) + // Manifest is like ImageSource.GetManifest, but the result is cached; it is OK to call this however often you need. + Manifest() ([]byte, error) + // 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) DockerTar() ([]byte, error) // ??? also, configure output directory From c38ed76969f8ca3aa8ee122ed5fa425f5fbed837 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20Trma=C4=8D?= Date: Mon, 16 May 2016 20:33:13 +0200 Subject: [PATCH 3/3] Rename GetIndendedDockerReference to IntendedDockerReference --- directory/directory.go | 4 ++-- docker/docker_image.go | 6 +++--- docker/docker_image_src.go | 4 ++-- openshift/openshift.go | 4 ++-- types/types.go | 8 ++++---- 5 files changed, 13 insertions(+), 13 deletions(-) diff --git a/directory/directory.go b/directory/directory.go index 49bb5765..e41854ec 100644 --- a/directory/directory.go +++ b/directory/directory.go @@ -77,10 +77,10 @@ func NewDirImageSource(dir string) types.ImageSource { return &dirImageSource{dir} } -// GetIntendedDockerReference returns the full, unambiguous, Docker reference for this image, _as specified by the user_ +// IntendedDockerReference returns the full, unambiguous, Docker reference for this image, _as specified by the user_ // (not as the image itself, or its underlying storage, claims). This can be used e.g. to determine which public keys are trusted for this image. // May be "" if unknown. -func (s *dirImageSource) GetIntendedDockerReference() string { +func (s *dirImageSource) IntendedDockerReference() string { return "" } diff --git a/docker/docker_image.go b/docker/docker_image.go index c9ab31b8..a708ddec 100644 --- a/docker/docker_image.go +++ b/docker/docker_image.go @@ -35,11 +35,11 @@ func NewDockerImage(img, certPath string, tlsVerify bool) (types.Image, error) { return &dockerImage{src: s}, nil } -// GetIntendedDockerReference returns the full, unambiguous, Docker reference for this image, _as specified by the user_ +// IntendedDockerReference returns the full, unambiguous, Docker reference for this image, _as specified by the user_ // (not as the image itself, or its underlying storage, claims). This can be used e.g. to determine which public keys are trusted for this image. // May be "" if unknown. -func (i *dockerImage) GetIntendedDockerReference() string { - return i.src.GetIntendedDockerReference() +func (i *dockerImage) IntendedDockerReference() string { + return i.src.IntendedDockerReference() } // Manifest is like ImageSource.GetManifest, but the result is cached; it is OK to call this however often you need. diff --git a/docker/docker_image_src.go b/docker/docker_image_src.go index 53bbd425..4277be8b 100644 --- a/docker/docker_image_src.go +++ b/docker/docker_image_src.go @@ -48,10 +48,10 @@ func NewDockerImageSource(img, certPath string, tlsVerify bool) (types.ImageSour return newDockerImageSource(img, certPath, tlsVerify) } -// GetIntendedDockerReference returns the full, unambiguous, Docker reference for this image, _as specified by the user_ +// IntendedDockerReference returns the full, unambiguous, Docker reference for this image, _as specified by the user_ // (not as the image itself, or its underlying storage, claims). This can be used e.g. to determine which public keys are trusted for this image. // May be "" if unknown. -func (s *dockerImageSource) GetIntendedDockerReference() string { +func (s *dockerImageSource) IntendedDockerReference() string { return fmt.Sprintf("%s:%s", s.ref.Name(), s.tag) } diff --git a/openshift/openshift.go b/openshift/openshift.go index 2e549c0d..6425a928 100644 --- a/openshift/openshift.go +++ b/openshift/openshift.go @@ -186,10 +186,10 @@ func NewOpenshiftImageSource(imageName, certPath string, tlsVerify bool) (types. }, nil } -// GetIntendedDockerReference returns the full, unambiguous, Docker reference for this image, _as specified by the user_ +// IntendedDockerReference returns the full, unambiguous, Docker reference for this image, _as specified by the user_ // (not as the image itself, or its underlying storage, claims). This can be used e.g. to determine which public keys are trusted for this image. // May be "" if unknown. -func (s *openshiftImageSource) GetIntendedDockerReference() string { +func (s *openshiftImageSource) IntendedDockerReference() string { return s.client.canonicalDockerReference() } diff --git a/types/types.go b/types/types.go index a8f0e82c..1f1a4626 100644 --- a/types/types.go +++ b/types/types.go @@ -30,10 +30,10 @@ type Repository interface { // ImageSource is a service, possibly remote (= slow), to download components of a single image. type ImageSource interface { - // GetIntendedDockerReference returns the full, unambiguous, Docker reference for this image, _as specified by the user_ + // IntendedDockerReference returns the full, unambiguous, Docker reference for this image, _as specified by the user_ // (not as the image itself, or its underlying storage, claims). This can be used e.g. to determine which public keys are trusted for this image. // May be "" if unknown. - GetIntendedDockerReference() string + IntendedDockerReference() string // GetManifest returns the image's manifest. It may use a remote (= slow) service. GetManifest() (manifest []byte, unverifiedCanonicalDigest string, err error) GetLayer(digest string) (io.ReadCloser, error) @@ -53,10 +53,10 @@ type ImageDestination interface { // Image is a Docker image in a repository. type Image interface { // ref to repository? - // GetIntendedDockerReference returns the full, unambiguous, Docker reference for this image, _as specified by the user_ + // IntendedDockerReference returns the full, unambiguous, Docker reference for this image, _as specified by the user_ // (not as the image itself, or its underlying storage, claims). This can be used e.g. to determine which public keys are trusted for this image. // May be "" if unknown. - GetIntendedDockerReference() string + IntendedDockerReference() string // Manifest is like ImageSource.GetManifest, but the result is cached; it is OK to call this however often you need. Manifest() ([]byte, error) // Signatures is like ImageSource.GetSignatures, but the result is cached; it is OK to call this however often you need.