From d4fc16cd47dc1b5cbe2846c6c2784a8c6b93191a Mon Sep 17 00:00:00 2001 From: Fedor Kanin Date: Fri, 26 Sep 2025 12:06:04 +0200 Subject: [PATCH 1/2] fix(images): use path.Join instead of url.JoinPath when prepending a custom registry to an image (#3306) --- image_substitutors_test.go | 8 ++++++++ options.go | 16 +++------------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/image_substitutors_test.go b/image_substitutors_test.go index ed4cf2631d..274ad1ee1f 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 From 193b35f10b2c524f1f4d70ddbbeaafc1d35fab1d Mon Sep 17 00:00:00 2001 From: Fedor Kanin <45014559+fedorkanin@users.noreply.github.com> Date: Mon, 29 Sep 2025 13:55:56 +0200 Subject: [PATCH 2/2] Update image_substitutors_test.go MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Manuel de la Peña --- image_substitutors_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/image_substitutors_test.go b/image_substitutors_test.go index 274ad1ee1f..fa9abfc775 100644 --- a/image_substitutors_test.go +++ b/image_substitutors_test.go @@ -67,7 +67,7 @@ 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) { + t.Run("registry-with-port", func(t *testing.T) { s := newPrependHubRegistry("my-registry:5000") img, err := s.Substitute("foo:latest")