mirror of https://github.com/docker/cli.git
re-introduced support for port numbers in docker registry URL
Signed-off-by: Carston Schilds <Carston.Schilds@visier.com>
(cherry picked from commit 2380481609
)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
fce24d5f8d
commit
217971d481
|
@ -74,7 +74,10 @@ func ConvertToHostname(maybeURL string) string {
|
||||||
if strings.Contains(stripped, "://") {
|
if strings.Contains(stripped, "://") {
|
||||||
u, err := url.Parse(stripped)
|
u, err := url.Parse(stripped)
|
||||||
if err == nil && u.Hostname() != "" {
|
if err == nil && u.Hostname() != "" {
|
||||||
return u.Hostname()
|
if u.Port() == "" {
|
||||||
|
return u.Hostname()
|
||||||
|
}
|
||||||
|
return u.Hostname() + ":" + u.Port()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hostName, _, _ := strings.Cut(stripped, "/")
|
hostName, _, _ := strings.Cut(stripped, "/")
|
||||||
|
|
|
@ -167,6 +167,23 @@ func TestConvertToHostname(t *testing.T) {
|
||||||
input: "ftp://example.com",
|
input: "ftp://example.com",
|
||||||
expected: "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 {
|
for _, tc := range tests {
|
||||||
tc := tc
|
tc := tc
|
||||||
|
|
Loading…
Reference in New Issue