|
|
|
@ -34,6 +34,10 @@ var (
|
|
|
|
|
referenceDelimiter = regexp.MustCompile(`[:]`)
|
|
|
|
|
errEmptyRepo = errors.New("parsed repo was empty")
|
|
|
|
|
errTooManyColons = errors.New("ref may only contain a single colon character (:) unless specifying a port number")
|
|
|
|
|
// ErrInvalid is returned when there is an invalid reference
|
|
|
|
|
ErrInvalid = errors.New("invalid reference")
|
|
|
|
|
// ErrHostnameRequired is returned when the hostname is required
|
|
|
|
|
ErrHostnameRequired = errors.New("hostname required")
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type (
|
|
|
|
@ -86,6 +90,7 @@ func (ref *Reference) FullName() string {
|
|
|
|
|
|
|
|
|
|
// validate makes sure the ref meets our criteria
|
|
|
|
|
func (ref *Reference) validate() error {
|
|
|
|
|
|
|
|
|
|
err := ref.validateRepo()
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
@ -100,7 +105,15 @@ func (ref *Reference) validateRepo() error {
|
|
|
|
|
}
|
|
|
|
|
// Makes sure the repo results in a parsable URL (similar to what is done
|
|
|
|
|
// with containerd reference parsing)
|
|
|
|
|
_, err := url.Parse(ref.Repo)
|
|
|
|
|
u, err := url.Parse("dummy://" + ref.Repo)
|
|
|
|
|
|
|
|
|
|
if u.Scheme != "dummy" {
|
|
|
|
|
return ErrInvalid
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if u.Host == "" {
|
|
|
|
|
return ErrHostnameRequired
|
|
|
|
|
}
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|