mirror of
https://github.com/containers/skopeo.git
synced 2025-06-28 15:47:34 +00:00
Add CanonicalDockerReference to ImageDestination
This is necessary to resolve the canonical form of a reference for signing it.
This commit is contained in:
parent
2e48975b8b
commit
da24e319af
@ -36,6 +36,10 @@ func NewDirImageDestination(dir string) types.ImageDestination {
|
||||
return &dirImageDestination{dir}
|
||||
}
|
||||
|
||||
func (d *dirImageDestination) CanonicalDockerReference() (string, error) {
|
||||
return "", fmt.Errorf("Can not determine canonical Docker reference for a local directory")
|
||||
}
|
||||
|
||||
func (d *dirImageDestination) PutManifest(manifest []byte) error {
|
||||
return ioutil.WriteFile(manifestPath(d.dir), manifest, 0644)
|
||||
}
|
||||
|
@ -752,6 +752,10 @@ func NewDockerImageDestination(img, certPath string, tlsVerify bool) (types.Imag
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (d *dockerImageDestination) CanonicalDockerReference() (string, error) {
|
||||
return fmt.Sprintf("%s:%s", d.ref.Name(), d.tag), nil
|
||||
}
|
||||
|
||||
func (d *dockerImageDestination) PutManifest(manifest []byte) error {
|
||||
// FIXME: This only allows upload by digest, not creating a tag. See the
|
||||
// corresponding comment in NewOpenshiftImageDestination.
|
||||
|
@ -268,6 +268,10 @@ func NewOpenshiftImageDestination(imageName, certPath string, tlsVerify bool) (t
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (d *openshiftImageDestination) CanonicalDockerReference() (string, error) {
|
||||
return fmt.Sprintf("%s/%s/%s:%s", d.client.baseURL.Host, d.client.namespace, d.client.stream, d.client.tag), nil
|
||||
}
|
||||
|
||||
func (d *openshiftImageDestination) PutManifest(manifest []byte) error {
|
||||
// Note: This does absolutely no kind/version checking or conversions.
|
||||
manifestDigest, err := dockerutils.ManifestDigest(manifest)
|
||||
|
@ -37,6 +37,8 @@ type ImageSource interface {
|
||||
|
||||
// ImageDestination is a service, possibly remote (= slow), to store components of a single image.
|
||||
type ImageDestination interface {
|
||||
// CanonicalDockerReference returns the full, unambiguous, Docker reference for this image (even if the user referred to the image using some shorthand notation).
|
||||
CanonicalDockerReference() (string, error)
|
||||
PutManifest([]byte) error
|
||||
PutLayer(digest string, stream io.Reader) error
|
||||
PutSignatures(signatures [][]byte) error
|
||||
|
Loading…
Reference in New Issue
Block a user