c219afdb4b
Add a trusted flag to force the cli to resolve a tag into a digest via the notary trust library and pull by digest. On push the flag the trust flag will indicate the digest and size of a manifest should be signed and push to a notary server. If a tag is given, the cli will resolve the tag into a digest and pull by digest. After pulling, if a tag is given the cli makes a request to tag the image. Use certificate directory for notary requests Read certificates using same logic used by daemon for registry requests. Catch JSON syntax errors from Notary client When an uncaught error occurs in Notary it may show up in Docker as a JSON syntax error, causing a confusing error message to the user. Provide a generic error when a JSON syntax error occurs. Catch expiration errors and wrap in additional context. Signed-off-by: Derek McGowan <derek@mcgstyle.net> (github: dmcgowan)
68 lines
1.4 KiB
Go
68 lines
1.4 KiB
Go
package registry
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/docker/distribution/digest"
|
|
)
|
|
|
|
// Reference represents a tag or digest within a repository
|
|
type Reference interface {
|
|
// HasDigest returns whether the reference has a verifiable
|
|
// content addressable reference which may be considered secure.
|
|
HasDigest() bool
|
|
|
|
// ImageName returns an image name for the given repository
|
|
ImageName(string) string
|
|
|
|
// Returns a string representation of the reference
|
|
String() string
|
|
}
|
|
|
|
type tagReference struct {
|
|
tag string
|
|
}
|
|
|
|
func (tr tagReference) HasDigest() bool {
|
|
return false
|
|
}
|
|
|
|
func (tr tagReference) ImageName(repo string) string {
|
|
return repo + ":" + tr.tag
|
|
}
|
|
|
|
func (tr tagReference) String() string {
|
|
return tr.tag
|
|
}
|
|
|
|
type digestReference struct {
|
|
digest digest.Digest
|
|
}
|
|
|
|
func (dr digestReference) HasDigest() bool {
|
|
return true
|
|
}
|
|
|
|
func (dr digestReference) ImageName(repo string) string {
|
|
return repo + "@" + dr.String()
|
|
}
|
|
|
|
func (dr digestReference) String() string {
|
|
return dr.digest.String()
|
|
}
|
|
|
|
// ParseReference parses a reference into either a digest or tag reference
|
|
func ParseReference(ref string) Reference {
|
|
if strings.Contains(ref, ":") {
|
|
dgst, err := digest.ParseDigest(ref)
|
|
if err == nil {
|
|
return digestReference{digest: dgst}
|
|
}
|
|
}
|
|
return tagReference{tag: ref}
|
|
}
|
|
|
|
// DigestReference creates a digest reference using a digest
|
|
func DigestReference(dgst digest.Digest) Reference {
|
|
return digestReference{digest: dgst}
|
|
}
|