Skip to content

Commit 3283e47

Browse files
committed
fix: Use leaf "image" field in preflight check results
1 parent f26818b commit 3283e47

File tree

4 files changed

+18
-18
lines changed

4 files changed

+18
-18
lines changed

pkg/webhook/preflight/nutanix/image.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func (c *imageCheck) Run(ctx context.Context) preflight.CheckResult {
4545
result.InternalError = true
4646
result.Causes = append(result.Causes, preflight.Cause{
4747
Message: fmt.Sprintf("failed to get VM Image: %s", err),
48-
Field: c.field,
48+
Field: c.field + ".image",
4949
})
5050
return result
5151
}
@@ -54,7 +54,7 @@ func (c *imageCheck) Run(ctx context.Context) preflight.CheckResult {
5454
result.Allowed = false
5555
result.Causes = append(result.Causes, preflight.Cause{
5656
Message: fmt.Sprintf("expected to find 1 VM Image, found %d", len(images)),
57-
Field: c.field,
57+
Field: c.field + ".image",
5858
})
5959
return result
6060
}

pkg/webhook/preflight/nutanix/image_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ func TestVMImageCheck(t *testing.T) {
127127
Causes: []preflight.Cause{
128128
{
129129
Message: "expected to find 1 VM Image, found 0",
130-
Field: "test-field",
130+
Field: "machineDetails.image",
131131
},
132132
},
133133
},
@@ -169,7 +169,7 @@ func TestVMImageCheck(t *testing.T) {
169169
Causes: []preflight.Cause{
170170
{
171171
Message: "expected to find 1 VM Image, found 2",
172-
Field: "test-field",
172+
Field: "machineDetails.image",
173173
},
174174
},
175175
},
@@ -193,7 +193,7 @@ func TestVMImageCheck(t *testing.T) {
193193
Causes: []preflight.Cause{
194194
{
195195
Message: "failed to get VM Image: api error",
196-
Field: "test-field",
196+
Field: "machineDetails.image",
197197
},
198198
},
199199
},
@@ -226,7 +226,7 @@ func TestVMImageCheck(t *testing.T) {
226226
Causes: []preflight.Cause{
227227
{
228228
Message: "failed to get VM Image: api error",
229-
Field: "test-field",
229+
Field: "machineDetails.image",
230230
},
231231
},
232232
},
@@ -262,7 +262,7 @@ func TestVMImageCheck(t *testing.T) {
262262
Causes: []preflight.Cause{
263263
{
264264
Message: "failed to get VM Image: failed to get data returned by ListImages",
265-
Field: "test-field",
265+
Field: "machineDetails.image",
266266
},
267267
},
268268
},
@@ -284,7 +284,7 @@ func TestVMImageCheck(t *testing.T) {
284284
// Create the check
285285
check := &imageCheck{
286286
machineDetails: tc.machineDetails,
287-
field: "test-field",
287+
field: "machineDetails",
288288
nclient: tc.nclient,
289289
}
290290

pkg/webhook/preflight/nutanix/imagekubernetesversioncheck.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func (c *imageKubernetesVersionCheck) Run(ctx context.Context) preflight.CheckRe
4343
Causes: []preflight.Cause{
4444
{
4545
Message: fmt.Sprintf("failed to get VM Image: %s", err),
46-
Field: c.field,
46+
Field: c.field + ".image",
4747
},
4848
},
4949
}
@@ -62,7 +62,7 @@ func (c *imageKubernetesVersionCheck) Run(ctx context.Context) preflight.CheckRe
6262
Causes: []preflight.Cause{
6363
{
6464
Message: err.Error(),
65-
Field: c.field,
65+
Field: c.field + ".image",
6666
},
6767
},
6868
}
@@ -127,7 +127,7 @@ func newVMImageKubernetesVersionChecks(
127127
&imageKubernetesVersionCheck{
128128
machineDetails: &cd.nutanixClusterConfigSpec.ControlPlane.Nutanix.MachineDetails,
129129
field: "cluster.spec.topology.variables[.name=clusterConfig]" +
130-
".value.nutanix.controlPlane.machineDetails.image",
130+
".value.nutanix.controlPlane.machineDetails",
131131
nclient: cd.nclient,
132132
clusterK8sVersion: clusterK8sVersion,
133133
},
@@ -140,7 +140,7 @@ func newVMImageKubernetesVersionChecks(
140140
&imageKubernetesVersionCheck{
141141
machineDetails: &nutanixWorkerNodeConfigSpec.Nutanix.MachineDetails,
142142
field: fmt.Sprintf("cluster.spec.topology.workers.machineDeployments[.name=%s]"+
143-
".variables[.name=workerConfig].value.nutanix.machineDetails.image", mdName),
143+
".variables[.name=workerConfig].value.nutanix.machineDetails", mdName),
144144
nclient: cd.nclient,
145145
clusterK8sVersion: clusterK8sVersion,
146146
},

pkg/webhook/preflight/nutanix/imagekubernetesversioncheck_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func TestVMImageCheckWithKubernetesVersion(t *testing.T) {
8080
Causes: []preflight.Cause{
8181
{
8282
Message: "cluster kubernetes version '1.32.3' is not part of image name 'kubedistro-ubuntu-22.04-vgpu-1.31.5-20250604180644'", //nolint:lll // cause message is long
83-
Field: "test-field",
83+
Field: "machineDetails.image",
8484
},
8585
},
8686
},
@@ -137,7 +137,7 @@ func TestVMImageCheckWithKubernetesVersion(t *testing.T) {
137137
Causes: []preflight.Cause{
138138
{
139139
Message: "cluster kubernetes version '1.32.3' is not part of image name 'my-custom-image-name'",
140-
Field: "test-field",
140+
Field: "machineDetails.image",
141141
},
142142
},
143143
},
@@ -169,7 +169,7 @@ func TestVMImageCheckWithKubernetesVersion(t *testing.T) {
169169
Causes: []preflight.Cause{
170170
{
171171
Message: "failed to parse kubernetes version 'invalid.version': No Major.Minor.Patch elements found",
172-
Field: "test-field",
172+
Field: "machineDetails.image",
173173
},
174174
},
175175
},
@@ -201,7 +201,7 @@ func TestVMImageCheckWithKubernetesVersion(t *testing.T) {
201201
Causes: []preflight.Cause{
202202
{
203203
Message: "VM image name is empty",
204-
Field: "test-field",
204+
Field: "machineDetails.image",
205205
},
206206
},
207207
},
@@ -258,7 +258,7 @@ func TestVMImageCheckWithKubernetesVersion(t *testing.T) {
258258
Causes: []preflight.Cause{
259259
{
260260
Message: "failed to get VM Image: some error",
261-
Field: "test-field",
261+
Field: "machineDetails.image",
262262
},
263263
},
264264
},
@@ -269,7 +269,7 @@ func TestVMImageCheckWithKubernetesVersion(t *testing.T) {
269269
t.Run(tc.name, func(t *testing.T) {
270270
check := &imageKubernetesVersionCheck{
271271
machineDetails: tc.machineDetails,
272-
field: "test-field",
272+
field: "machineDetails",
273273
nclient: tc.nclient,
274274
clusterK8sVersion: tc.clusterK8sVersion,
275275
}

0 commit comments

Comments
 (0)