Skip to content

Commit 042a6b0

Browse files
committed
refactor(test): extract patch version logic into separate function
1 parent ddebc38 commit 042a6b0

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

test/e2e/testutils/apiserver/create.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"context"
2020
"fmt"
2121
"os"
22+
"strings"
2223

2324
batchv1 "k8s.io/api/batch/v1"
2425
corev1 "k8s.io/api/core/v1"
@@ -61,7 +62,7 @@ func CreateKubectlJob(ctx context.Context, cl client.Client, namespace string, v
6162
Spec: corev1.PodSpec{
6263
Containers: []corev1.Container{{
6364
Name: containerName,
64-
Image: fmt.Sprintf("%s:%s.%s", image, v.Major, v.Minor),
65+
Image: fmt.Sprintf("%s:%s.%s.%s", image, v.Major, v.Minor, patchVersion(v)),
6566
Args: []string{"get", "pods", "-n", namespace, "--no-headers", "-o", "custom-columns=:.metadata.name"},
6667
Resources: util.ResourceRequirements(),
6768
}},
@@ -113,3 +114,12 @@ func CreateRoleBinding(ctx context.Context, cl client.Client, namespace string)
113114
}
114115
return cl.Create(ctx, rb)
115116
}
117+
118+
func patchVersion(v *version.Info) string {
119+
tmp := strings.Split(v.GitVersion, ".")
120+
if len(tmp) < 3 {
121+
return ""
122+
}
123+
patch := tmp[2]
124+
return strings.Split(patch, "+")[0]
125+
}

0 commit comments

Comments
 (0)