pull/9662/head
Medya Gh 2020-11-10 13:21:11 -08:00
parent d7fe968bde
commit 52ef75121d
1 changed files with 21 additions and 3 deletions

View File

@ -293,8 +293,7 @@ func testPulledImages(ctx context.Context, t *testing.T, profile string, version
found := map[string]bool{}
for _, img := range jv["images"] {
for _, i := range img.Tags {
// Remove container-specific prefixes for naming consistency
i = strings.TrimPrefix(i, "localhost/")
i = trimImage(i)
if defaultImage(i) {
found[i] = true
} else {
@ -302,10 +301,16 @@ func testPulledImages(ctx context.Context, t *testing.T, profile string, version
}
}
}
want, err := images.Kubeadm("", version)
wantRaw, err := images.Kubeadm("", version)
if err != nil {
t.Errorf("failed to get kubeadm images for %s : %v", version, err)
}
// we need to trim the want raw, because if runtime is docker it will not report the full name with docker.io as prefix
want := []string{}
for i := range wantRaw {
want = append(want, trimImage(i))
}
gotImages := []string{}
for k := range found {
gotImages = append(gotImages, k)
@ -354,6 +359,19 @@ func testPause(ctx context.Context, t *testing.T, profile string) {
}
// Remove container-specific prefixes for naming consistency
// for example in `docker` runtime we get this:
// $ docker@minikube:~$ sudo crictl images -o json | grep dash
// "kubernetesui/dashboard:v2.0.3"
// but for 'containerd' we get full name
// $ docker@minikube:~$ sudo crictl images -o json | grep dash
// "docker.io/kubernetesui/dashboard:v2.0.3"
func trimImage(name string) string {
name = strings.TrimPrefix(name, "docker.io/")
name = strings.TrimPrefix(name, "localhost/")
return name
}
// defaultImage returns true if this image is expected in a default minikube install
func defaultImage(name string) bool {
if strings.Contains(name, ":latest") {