Skip to content

Commit 37533c2

Browse files
authoredJun 26, 2024··
Merge pull request #5197 from thaJeztah/27.0_backport_fix_custom_ports
[27.0 backport] re-introduced support for port numbers in docker registry URL
2 parents fce24d5 + 217971d commit 37533c2

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed
 

‎cli/config/credentials/file_store.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,10 @@ func ConvertToHostname(maybeURL string) string {
7474
if strings.Contains(stripped, "://") {
7575
u, err := url.Parse(stripped)
7676
if err == nil && u.Hostname() != "" {
77-
return u.Hostname()
77+
if u.Port() == "" {
78+
return u.Hostname()
79+
}
80+
return u.Hostname() + ":" + u.Port()
7881
}
7982
}
8083
hostName, _, _ := strings.Cut(stripped, "/")

‎cli/config/credentials/file_store_test.go

+17
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,23 @@ func TestConvertToHostname(t *testing.T) {
167167
input: "ftp://example.com",
168168
expected: "example.com",
169169
},
170+
// should support non-standard port in registry url
171+
{
172+
input: "example.com:6555",
173+
expected: "example.com:6555",
174+
},
175+
{
176+
input: "http://example.com:6555",
177+
expected: "example.com:6555",
178+
},
179+
{
180+
input: "https://example.com:6555",
181+
expected: "example.com:6555",
182+
},
183+
{
184+
input: "https://example.com:6555/v2/",
185+
expected: "example.com:6555",
186+
},
170187
}
171188
for _, tc := range tests {
172189
tc := tc

0 commit comments

Comments
 (0)
Please sign in to comment.