parent
326f0cfa2f
commit
5c292c61c6
1437 changed files with 208886 additions and 87131 deletions
28
vendor/github.com/google/go-containerregistry/pkg/name/digest.go
generated
vendored
28
vendor/github.com/google/go-containerregistry/pkg/name/digest.go
generated
vendored
|
|
@ -15,15 +15,14 @@
|
|||
package name
|
||||
|
||||
import (
|
||||
// nolint: depguard
|
||||
_ "crypto/sha256" // Recommended by go-digest.
|
||||
"strings"
|
||||
|
||||
"github.com/opencontainers/go-digest"
|
||||
)
|
||||
|
||||
const (
|
||||
// These have the form: sha256:<hex string>
|
||||
// TODO(dekkagaijin): replace with opencontainers/go-digest or docker/distribution's validation.
|
||||
digestChars = "sh:0123456789abcdef"
|
||||
digestDelim = "@"
|
||||
)
|
||||
const digestDelim = "@"
|
||||
|
||||
// Digest stores a digest name in a structured form.
|
||||
type Digest struct {
|
||||
|
|
@ -60,10 +59,6 @@ func (d Digest) String() string {
|
|||
return d.original
|
||||
}
|
||||
|
||||
func checkDigest(name string) error {
|
||||
return checkElement("digest", name, digestChars, 7+64, 7+64)
|
||||
}
|
||||
|
||||
// NewDigest returns a new Digest representing the given name.
|
||||
func NewDigest(name string, opts ...Option) (Digest, error) {
|
||||
// Split on "@"
|
||||
|
|
@ -72,10 +67,13 @@ func NewDigest(name string, opts ...Option) (Digest, error) {
|
|||
return Digest{}, newErrBadName("a digest must contain exactly one '@' separator (e.g. registry/repository@digest) saw: %s", name)
|
||||
}
|
||||
base := parts[0]
|
||||
digest := parts[1]
|
||||
|
||||
// Always check that the digest is valid.
|
||||
if err := checkDigest(digest); err != nil {
|
||||
dig := parts[1]
|
||||
prefix := digest.Canonical.String() + ":"
|
||||
if !strings.HasPrefix(dig, prefix) {
|
||||
return Digest{}, newErrBadName("unsupported digest algorithm: %s", dig)
|
||||
}
|
||||
hex := strings.TrimPrefix(dig, prefix)
|
||||
if err := digest.Canonical.Validate(hex); err != nil {
|
||||
return Digest{}, err
|
||||
}
|
||||
|
||||
|
|
@ -90,7 +88,7 @@ func NewDigest(name string, opts ...Option) (Digest, error) {
|
|||
}
|
||||
return Digest{
|
||||
Repository: repo,
|
||||
digest: digest,
|
||||
digest: dig,
|
||||
original: name,
|
||||
}, nil
|
||||
}
|
||||
|
|
|
|||
8
vendor/github.com/google/go-containerregistry/pkg/name/errors.go
generated
vendored
8
vendor/github.com/google/go-containerregistry/pkg/name/errors.go
generated
vendored
|
|
@ -28,8 +28,14 @@ func (e *ErrBadName) Error() string {
|
|||
return e.info
|
||||
}
|
||||
|
||||
// Is reports whether target is an error of type ErrBadName
|
||||
func (e *ErrBadName) Is(target error) bool {
|
||||
var berr *ErrBadName
|
||||
return errors.As(target, &berr)
|
||||
}
|
||||
|
||||
// newErrBadName returns a ErrBadName which returns the given formatted string from Error().
|
||||
func newErrBadName(fmtStr string, args ...interface{}) *ErrBadName {
|
||||
func newErrBadName(fmtStr string, args ...any) *ErrBadName {
|
||||
return &ErrBadName{fmt.Sprintf(fmtStr, args...)}
|
||||
}
|
||||
|
||||
|
|
|
|||
14
vendor/github.com/google/go-containerregistry/pkg/name/ref.go
generated
vendored
14
vendor/github.com/google/go-containerregistry/pkg/name/ref.go
generated
vendored
|
|
@ -56,16 +56,16 @@ type stringConst string
|
|||
// To discourage its use in scenarios where the value is not known at code
|
||||
// authoring time, it must be passed a string constant:
|
||||
//
|
||||
// const str = "valid/string"
|
||||
// MustParseReference(str)
|
||||
// MustParseReference("another/valid/string")
|
||||
// MustParseReference(str + "/and/more")
|
||||
// const str = "valid/string"
|
||||
// MustParseReference(str)
|
||||
// MustParseReference("another/valid/string")
|
||||
// MustParseReference(str + "/and/more")
|
||||
//
|
||||
// These will not compile:
|
||||
//
|
||||
// var str = "valid/string"
|
||||
// MustParseReference(str)
|
||||
// MustParseReference(strings.Join([]string{"valid", "string"}, "/"))
|
||||
// var str = "valid/string"
|
||||
// MustParseReference(str)
|
||||
// MustParseReference(strings.Join([]string{"valid", "string"}, "/"))
|
||||
func MustParseReference(s stringConst, opts ...Option) Reference {
|
||||
ref, err := ParseReference(string(s), opts...)
|
||||
if err != nil {
|
||||
|
|
|
|||
6
vendor/github.com/google/go-containerregistry/pkg/name/registry.go
generated
vendored
6
vendor/github.com/google/go-containerregistry/pkg/name/registry.go
generated
vendored
|
|
@ -17,6 +17,7 @@ package name
|
|||
import (
|
||||
"net"
|
||||
"net/url"
|
||||
"path"
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
|
@ -50,6 +51,11 @@ func (r Registry) String() string {
|
|||
return r.Name()
|
||||
}
|
||||
|
||||
// Repo returns a Repository in the Registry with the given name.
|
||||
func (r Registry) Repo(repo ...string) Repository {
|
||||
return Repository{Registry: r, repository: path.Join(repo...)}
|
||||
}
|
||||
|
||||
// Scope returns the scope required to access the registry.
|
||||
func (r Registry) Scope(string) string {
|
||||
// The only resource under 'registry' is 'catalog'. http://goo.gl/N9cN9Z
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue