Skip to content

Commit af10540

Browse files
fix(preflight): remove 'nkp' mentions in examples and tests
1 parent 6e568a5 commit af10540

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

pkg/webhook/preflight/nutanix/imagekubernetesversioncheck.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ import (
1515
"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/pkg/webhook/preflight"
1616
)
1717

18-
// Examples: nkp-ubuntu-22.04-vgpu-1.32.3-20250604180644, nkp-rocky-9.5-release-cis-1.32.3-20250430150550.
1918
// The regex captures the Kubernetes version in the format of 1.x.y, where x and y are digits.
19+
// Example: kubedistro-rocky-9.5-vgpu-1.32.3-20250604180644 -> 1.32.3.
2020
var kubernetesVersionRegex = regexp.MustCompile(`(?i)\b[vV]?(1\.\d+(?:\.\d+)?)\b`)
2121

2222
type imageKubernetesVersionCheck struct {
@@ -107,8 +107,8 @@ func (c *imageKubernetesVersionCheck) checkKubernetesVersion(image *vmmv4.Image)
107107
}
108108

109109
// extractKubernetesVersionFromImageName extracts the Kubernetes version from the given image name.
110-
// It expects something that looks like a kubernetes version in the image name i.e. 1.x.y?,
111-
// Examples: nkp-ubuntu-22.04-vgpu-1.32.3-20250604180644 -> 1.32.3.
110+
// It expects something that looks like a kubernetes version in the image name i.e. 1.x.y?.
111+
// Examples: kubedistro-rocky-9.5-vgpu-1.32.3-20250604180644 -> 1.32.3.
112112
func extractKubernetesVersionFromImageName(imageName string) (string, error) {
113113
matches := kubernetesVersionRegex.FindStringSubmatch(imageName)
114114
if len(matches) < 2 {

pkg/webhook/preflight/nutanix/imagekubernetesversioncheck_test.go

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,55 +27,55 @@ func TestExtractKubernetesVersionFromImageName(t *testing.T) {
2727
wantErr bool
2828
}{
2929
{
30-
name: "nkp ubuntu vgpu image",
31-
imageName: "nkp-ubuntu-22.04-vgpu-1.32.3-20250604180644",
30+
name: "kubedistro ubuntu vgpu image",
31+
imageName: "kubedistro-ubuntu-22.04-vgpu-1.32.3-20250604180644",
3232
want: "1.32.3",
3333
wantErr: false,
3434
},
3535
{
36-
name: "nkp rocky release cis image",
37-
imageName: "nkp-rocky-9.5-release-cis-1.32.3-20250430150550",
36+
name: "kubedistro rocky release cis image",
37+
imageName: "kubedistro-rocky-9.5-release-cis-1.32.3-20250430150550",
3838
want: "1.32.3",
3939
wantErr: false,
4040
},
4141
{
42-
name: "nkp rhel fips image",
43-
imageName: "nkp-rhel-8.10-fips-1.32.3-20250505212227",
42+
name: "kubedistro rhel fips image",
43+
imageName: "kubedistro-rhel-8.10-fips-1.32.3-20250505212227",
4444
want: "1.32.3",
4545
wantErr: false,
4646
},
4747
{
48-
name: "nkp rocky basic image",
49-
imageName: "nkp-rocky-9.5-1.32.3-20250514222748",
48+
name: "kubedistro rocky basic image",
49+
imageName: "kubedistro-rocky-9.5-1.32.3-20250514222748",
5050
want: "1.32.3",
5151
wantErr: false,
5252
},
5353
{
5454
name: "different k8s version",
55-
imageName: "nkp-ubuntu-22.04-1.31.5-20250101000000",
55+
imageName: "kubedistro-ubuntu-22.04-1.31.5-20250101000000",
5656
want: "1.31.5",
5757
wantErr: false,
5858
},
5959
{
60-
name: "custom image name with kubernetes-version at end", // e.g., not following NKP naming convention
60+
name: "custom image name with kubernetes-version at end", // e.g., not following kubedistro naming convention
6161
imageName: "custom-image-v1.23",
6262
want: "1.23",
6363
wantErr: false,
6464
},
6565
{
66-
name: "custom image name with kubernetes version in middle", // e.g., not following NKP naming convention
66+
name: "custom image name with kubernetes version in middle", // e.g., not following kubedistro naming convention
6767
imageName: "custom-v1.23.1-image",
6868
want: "1.23.1",
6969
wantErr: false,
7070
},
7171
{
72-
name: "custom image name with kubernetes version in start", // e.g., not following NKP naming convention
72+
name: "custom image name with kubernetes version in start", // e.g., not following kubedistro naming convention
7373
imageName: "v1.23.1-alpha-custom-image",
7474
want: "1.23.1",
7575
wantErr: false,
7676
},
7777
{
78-
name: "custom image name - no match", // e.g., not following NKP naming convention
78+
name: "custom image name - no match", // e.g., not following kubedistro naming convention
7979
imageName: "my-custom-image-name",
8080
want: "",
8181
wantErr: true,
@@ -119,7 +119,7 @@ func TestVMImageCheckWithKubernetesVersion(t *testing.T) {
119119
err := resp.SetData(vmmv4.Image{
120120
ObjectType_: ptr.To("vmm.v4.content.Image"),
121121
ExtId: ptr.To("test-uuid"),
122-
Name: ptr.To("nkp-ubuntu-22.04-vgpu-1.32.3-20250604180644"),
122+
Name: ptr.To("kubedistro-ubuntu-22.04-vgpu-1.32.3-20250604180644"),
123123
})
124124
require.NoError(t, err)
125125
return resp, nil
@@ -144,7 +144,7 @@ func TestVMImageCheckWithKubernetesVersion(t *testing.T) {
144144
err := resp.SetData(vmmv4.Image{
145145
ObjectType_: ptr.To("vmm.v4.content.Image"),
146146
ExtId: ptr.To("test-uuid"),
147-
Name: ptr.To("nkp-ubuntu-22.04-vgpu-1.31.5-20250604180644"),
147+
Name: ptr.To("kubedistro-ubuntu-22.04-vgpu-1.31.5-20250604180644"),
148148
})
149149
require.NoError(t, err)
150150
return resp, nil
@@ -162,7 +162,7 @@ func TestVMImageCheckWithKubernetesVersion(t *testing.T) {
162162
Error: true,
163163
Causes: []preflight.Cause{
164164
{
165-
Message: "kubernetes version mismatch: cluster version '1.32.3' does not match image version '1.31.5' (from image name 'nkp-ubuntu-22.04-vgpu-1.31.5-20250604180644')", //nolint:lll // cause is long
165+
Message: "kubernetes version mismatch: cluster version '1.32.3' does not match image version '1.31.5' (from image name 'kubedistro-ubuntu-22.04-vgpu-1.31.5-20250604180644')", //nolint:lll // cause is long
166166
Field: "test-field",
167167
},
168168
},

0 commit comments

Comments
 (0)