From 8cb9ab7095c885e1f8d9bea3a28229f58ba59a5e Mon Sep 17 00:00:00 2001 From: Juned Memon Date: Sat, 9 May 2020 18:05:28 +0530 Subject: [PATCH] Fixes repo parsing Signed-off-by: Juned Memon --- internal/experimental/registry/reference.go | 14 +------------- internal/experimental/registry/reference_test.go | 7 +++++++ 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/internal/experimental/registry/reference.go b/internal/experimental/registry/reference.go index 73c409ba2..13d3d046f 100644 --- a/internal/experimental/registry/reference.go +++ b/internal/experimental/registry/reference.go @@ -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 } diff --git a/internal/experimental/registry/reference_test.go b/internal/experimental/registry/reference_test.go index bb53ebab8..aae03ad99 100644 --- a/internal/experimental/registry/reference_test.go +++ b/internal/experimental/registry/reference_test.go @@ -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)