Fixes repo parsing

Signed-off-by: Juned Memon <junaid18183@gmail.com>
pull/8089/head
Juned Memon 5 years ago
parent b473f8adec
commit 8cb9ab7095
No known key found for this signature in database
GPG Key ID: B7C1868E3994DA9E

@ -34,10 +34,6 @@ 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 (
@ -105,15 +101,7 @@ func (ref *Reference) validateRepo() error {
}
// Makes sure the repo results in a parsable URL (similar to what is done
// with containerd reference parsing)
u, err := url.Parse("dummy://" + ref.Repo)
if u.Scheme != "dummy" {
return ErrInvalid
}
if u.Host == "" {
return ErrHostnameRequired
}
_, err := url.Parse("dummy://" + ref.Repo)
return err
}

@ -81,6 +81,13 @@ func TestParseReference(t *testing.T) {
is.Equal("1.5.0", ref.Tag)
is.Equal("myrepo:5001/mychart:1.5.0", ref.FullName())
s = "127.0.0.1:5001/mychart:1.5.0"
ref, err = ParseReference(s)
is.NoError(err)
is.Equal("127.0.0.1:5001/mychart", ref.Repo)
is.Equal("1.5.0", ref.Tag)
is.Equal("127.0.0.1:5001/mychart:1.5.0", ref.FullName())
s = "localhost:5000/mychart:latest"
ref, err = ParseReference(s)
is.NoError(err)

Loading…
Cancel
Save