diff --git a/image_substitutors_test.go b/image_substitutors_test.go index ed4cf2631d..fa9abfc775 100644 --- a/image_substitutors_test.go +++ b/image_substitutors_test.go @@ -66,6 +66,14 @@ func TestPrependHubRegistrySubstitutor(t *testing.T) { require.Equalf(t, "my-registry/org/user/foo:latest", img, "expected my-registry/org/foo:latest, got %s", img) }) + + t.Run("registry-with-port", func(t *testing.T) { + s := newPrependHubRegistry("my-registry:5000") + + img, err := s.Substitute("foo:latest") + require.NoError(t, err) + require.Equalf(t, "my-registry:5000/foo:latest", img, "expected my-registry:5000/foo:latest, got %s", img) + }) }) t.Run("should not prepend the hub registry to the image name", func(t *testing.T) { diff --git a/options.go b/options.go index a930c54104..007eaa774e 100644 --- a/options.go +++ b/options.go @@ -5,7 +5,7 @@ import ( "errors" "fmt" "maps" - "net/url" + "path" "time" "dario.cat/mergo" @@ -196,12 +196,7 @@ func (c CustomHubSubstitutor) Substitute(image string) (string, error) { } } - result, err := url.JoinPath(c.hub, image) - if err != nil { - return "", err - } - - return result, nil + return path.Join(c.hub, image), nil } // prependHubRegistry represents a way to prepend a custom Hub registry to the image name, @@ -244,12 +239,7 @@ func (p prependHubRegistry) Substitute(image string) (string, error) { } } - result, err := url.JoinPath(p.prefix, image) - if err != nil { - return "", err - } - - return result, nil + return path.Join(p.prefix, image), nil } // WithImageSubstitutors sets the image substitutors for a container