Skip to content

Commit

Permalink
oci.DaemonHost handle empty hostnames
Browse files Browse the repository at this point in the history
This handles DOCKER_HOST='tcp://:'

Fixes #17452
  • Loading branch information
pnasrat committed Oct 25, 2023
1 parent d437eed commit 92c7832
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/drivers/kic/oci/oci.go
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,9 @@ func DaemonHost(driver string) string {
if dh := os.Getenv(constants.DockerHostEnv); dh != "" {
if u, err := url.Parse(dh); err == nil {
if u.Host != "" {
return u.Hostname()
if hostname := u.Hostname(); hostname != "" {
return u.Hostname()
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions pkg/drivers/kic/oci/oci_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ func TestDaemonHost(t *testing.T) {
{"docker", "", "unix:///var/run/something", "127.0.0.1", false},
{"docker", "", "tcp://127.0.0.1/foo", "127.0.0.1", true},
{"docker", "", "ssh://127.0.0.1/bar", "127.0.0.1", true},
{"docker", "", "tcp://:", "127.0.0.1", true},
}
for _, test := range tests {
t.Setenv("CONTAINER_HOST", test.containerHost)
Expand Down

0 comments on commit 92c7832

Please sign in to comment.