Skip to content

Commit 3dcc8fc

Browse files
committed
fixup! feat: Nutanix VM image preflight check
Fix formatting, precommit and linter errors
1 parent 7a844bc commit 3dcc8fc

File tree

3 files changed

+28
-7
lines changed

3 files changed

+28
-7
lines changed

pkg/webhook/preflight/nutanix/credentials.go

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Copyright 2025 Nutanix. All rights reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
14
package nutanix
25

36
import (
@@ -22,7 +25,10 @@ func newV4Client(ctx context.Context,
2225
client ctrlclient.Client,
2326
clusterNamespace string,
2427
prismCentralEndpointSpec *carenv1.NutanixPrismCentralEndpointSpec,
25-
) (*prismv4.Client, []preflight.Cause) {
28+
) (
29+
*prismv4.Client,
30+
[]preflight.Cause,
31+
) {
2632
credentials, causes := getCredentials(ctx, client, clusterNamespace, prismCentralEndpointSpec)
2733
if len(causes) > 0 {
2834
return nil, causes
@@ -46,7 +52,10 @@ func getCredentials(
4652
client ctrlclient.Client,
4753
clusterNamespace string,
4854
prismCentralEndpointSpec *carenv1.NutanixPrismCentralEndpointSpec,
49-
) (*prismgoclient.Credentials, []preflight.Cause) {
55+
) (
56+
*prismgoclient.Credentials,
57+
[]preflight.Cause,
58+
) {
5059
if prismCentralEndpointSpec == nil {
5160
return nil, []preflight.Cause{
5261
{
@@ -59,8 +68,9 @@ func getCredentials(
5968
if prismCentralEndpointSpec.Credentials.SecretRef.Name == "" {
6069
return nil, []preflight.Cause{
6170
{
62-
Message: "Prism Central credentials reference is missing the name",
63-
Field: "cluster.spec.topology.variables[.name=clusterConfig].nutanix.prismCentralEndpoint.credentials.secretRef.name",
71+
Message: "Prism Central credentials zreference is missing the name",
72+
Field: "cluster.spec.topology.variables[.name=clusterConfig]" +
73+
".nutanix.prismCentralEndpoint.credentials.secretRef.name",
6474
},
6575
}
6676
}
@@ -85,7 +95,7 @@ func getCredentials(
8595
if len(credentialsSecret.Data) == 0 {
8696
return nil, []preflight.Cause{
8797
{
88-
Message: fmt.Sprintf("credentials Secret has no data"),
98+
Message: "credentials Secret has no data",
8999
Field: "cluster.spec.topology.variables[.name=clusterConfig].nutanix.prismCentralEndpoint.credentials.secretRef",
90100
},
91101
}

pkg/webhook/preflight/nutanix/image.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Copyright 2025 Nutanix. All rights reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
14
package nutanix
25

36
import (
@@ -26,7 +29,7 @@ func newVMImageCheck(
2629
Error: true,
2730
Causes: []preflight.Cause{
2831
{
29-
Message: fmt.Sprintf("NutanixNodeSpec is missing"),
32+
Message: "NutanixNodeSpec is missing",
3033
Field: nutanixNodeSpecField,
3134
},
3235
},

pkg/webhook/preflight/nutanix/specs.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Copyright 2025 Nutanix. All rights reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
14
package nutanix
25

36
import (
@@ -12,7 +15,12 @@ import (
1215

1316
func specsFromCluster(
1417
cluster *clusterv1.Cluster,
15-
) (*carenv1.NutanixPrismCentralEndpointSpec, *carenv1.NutanixNodeSpec, map[string]*carenv1.NutanixNodeSpec, []preflight.Cause) {
18+
) (
19+
*carenv1.NutanixPrismCentralEndpointSpec,
20+
*carenv1.NutanixNodeSpec,
21+
map[string]*carenv1.NutanixNodeSpec,
22+
[]preflight.Cause,
23+
) {
1624
var prismCentralEndpointSpec *carenv1.NutanixPrismCentralEndpointSpec
1725
var controlPlaneNutanixNodeSpec *carenv1.NutanixNodeSpec
1826
nutanixNodeSpecByMachineDeploymentName := make(map[string]*carenv1.NutanixNodeSpec)

0 commit comments

Comments
 (0)