Skip to content

Commit

Permalink
re-introduced support for port numbers in docker registry URL
Browse files Browse the repository at this point in the history
Signed-off-by: Carston Schilds <[email protected]>
(cherry picked from commit 2380481)
Signed-off-by: Sebastiaan van Stijn <[email protected]>
  • Loading branch information
CarstonSchilds authored and thaJeztah committed Jun 26, 2024
1 parent fce24d5 commit 217971d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cli/config/credentials/file_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,10 @@ func ConvertToHostname(maybeURL string) string {
if strings.Contains(stripped, "://") {
u, err := url.Parse(stripped)
if err == nil && u.Hostname() != "" {
return u.Hostname()
if u.Port() == "" {
return u.Hostname()
}
return u.Hostname() + ":" + u.Port()
}
}
hostName, _, _ := strings.Cut(stripped, "/")
Expand Down
17 changes: 17 additions & 0 deletions cli/config/credentials/file_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,23 @@ func TestConvertToHostname(t *testing.T) {
input: "ftp://example.com",
expected: "example.com",
},
// should support non-standard port in registry url
{
input: "example.com:6555",
expected: "example.com:6555",
},
{
input: "http://example.com:6555",
expected: "example.com:6555",
},
{
input: "https://example.com:6555",
expected: "example.com:6555",
},
{
input: "https://example.com:6555/v2/",
expected: "example.com:6555",
},
}
for _, tc := range tests {
tc := tc
Expand Down

0 comments on commit 217971d

Please sign in to comment.