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.
This commit is contained in:
Miloslav Trmač 2016-05-16 20:29:52 +02:00
parent dc7a05ebf9
commit 119609b871
3 changed files with 12 additions and 10 deletions

View File

@ -23,7 +23,7 @@ var inspectCmd = cli.Command{
logrus.Fatal(err) logrus.Fatal(err)
} }
if c.Bool("raw") { if c.Bool("raw") {
b, err := img.GetManifest() b, err := img.Manifest()
if err != nil { if err != nil {
logrus.Fatal(err) logrus.Fatal(err)
} }

View File

@ -22,7 +22,7 @@ type dockerImage struct {
src *dockerImageSource src *dockerImageSource
digest string digest string
rawManifest []byte 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 // NewDockerImage returns a new Image interface type after setting up
@ -42,16 +42,16 @@ func (i *dockerImage) GetIntendedDockerReference() string {
return i.src.GetIntendedDockerReference() return i.src.GetIntendedDockerReference()
} }
// GetManifest is like ImageSource.GetManifest, but the result is cached; it is OK to call this however often you need. // Manifest 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) { func (i *dockerImage) Manifest() ([]byte, error) {
if err := i.retrieveRawManifest(); err != nil { if err := i.retrieveRawManifest(); err != nil {
return nil, err return nil, err
} }
return i.rawManifest, nil return i.rawManifest, nil
} }
// GetSignatures is like ImageSource.GetSignatures, but the result is cached; it is OK to call this however often you need. // Signatures 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) { func (i *dockerImage) Signatures() ([][]byte, error) {
if i.cachedSignatures == nil { if i.cachedSignatures == nil {
sigs, err := i.src.GetSignatures() sigs, err := i.src.GetSignatures()
if err != nil { if err != nil {

View File

@ -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. // (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. // May be "" if unknown.
GetIntendedDockerReference() string GetIntendedDockerReference() string
// GetManifest returns the image's manifest. It may use a remote (= slow) service.
GetManifest() (manifest []byte, unverifiedCanonicalDigest string, err error) GetManifest() (manifest []byte, unverifiedCanonicalDigest string, err error)
GetLayer(digest string) (io.ReadCloser, error) GetLayer(digest string) (io.ReadCloser, error)
// GetSignatures returns the image's signatures. It may use a remote (= slow) service.
GetSignatures() ([][]byte, error) 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. // (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. // May be "" if unknown.
GetIntendedDockerReference() string GetIntendedDockerReference() string
// GetManifest is like ImageSource.GetManifest, but the result is cached; it is OK to call this however often you need. // Manifest is like ImageSource.GetManifest, but the result is cached; it is OK to call this however often you need.
GetManifest() ([]byte, error) Manifest() ([]byte, error)
// GetSignatures is like ImageSource.GetSignatures, but the result is cached; it is OK to call this however often you need. // Signatures is like ImageSource.GetSignatures, but the result is cached; it is OK to call this however often you need.
GetSignatures() ([][]byte, error) Signatures() ([][]byte, error)
Layers(layers ...string) error // configure download directory? Call it DownloadLayers? Layers(layers ...string) error // configure download directory? Call it DownloadLayers?
Inspect() (ImageManifest, error) Inspect() (ImageManifest, error)
DockerTar() ([]byte, error) // ??? also, configure output directory DockerTar() ([]byte, error) // ??? also, configure output directory