diff --git a/pkg/client/tools.go b/pkg/client/tools.go index c4cb00573..e2c8bddbe 100644 --- a/pkg/client/tools.go +++ b/pkg/client/tools.go @@ -310,12 +310,17 @@ func isFile(image string) bool { } func dockerSpecialImageNameEqual(requestedImageName string, runtimeImageName string) bool { - if strings.HasPrefix(requestedImageName, "docker.io/") { - return dockerSpecialImageNameEqual(strings.TrimPrefix(requestedImageName, "docker.io/"), runtimeImageName) + prefixes := []string{ + "docker.io/library/", + "docker.io/", + "library/", } - if strings.HasPrefix(requestedImageName, "library/") { - return imageNamesEqual(strings.TrimPrefix(requestedImageName, "library/"), runtimeImageName) + for _, prefix := range prefixes { + if strings.HasPrefix(requestedImageName, prefix) { + return imageNamesEqual(strings.TrimPrefix(requestedImageName, prefix), runtimeImageName) + } + } return false diff --git a/pkg/client/tools_test.go b/pkg/client/tools_test.go index cda024b04..684a67e4a 100644 --- a/pkg/client/tools_test.go +++ b/pkg/client/tools_test.go @@ -46,6 +46,7 @@ func Test_findRuntimeImage(T *testing.T) { "registry:1234/one/two:latest", "registry:1234/one/two/three/four:version", "registry:1234/one/two/three/four:latest", + "one/two:latest", } tests := map[string]struct { @@ -143,6 +144,16 @@ func Test_findRuntimeImage(T *testing.T) { expectedFound: true, givenRequestedImageName: "docker.io/library/busybox:version", }, + "docker.io is used as registry": { + expectedImageName: "one/two:latest", + expectedFound: true, + givenRequestedImageName: "docker.io/one/two:latest", + }, + "docker.io is used as registry, no version tag": { + expectedImageName: "one/two:latest", + expectedFound: true, + givenRequestedImageName: "docker.io/one/two", + }, "unknown image": { expectedFound: false, givenRequestedImageName: "unknown",