Skip to content

Commit e5d585a

Browse files
authored
fix: Fix typo in field name; use one-line strings to prevent future typos (#1206)
**What problem does this PR solve?**: There was an extra period in a field, introduced when I manually split the field across two lines, to appease the linter. Fields are long strings, and easier to read and maintain if we don't split them up. **Which issue(s) this PR fixes**: Fixes # **How Has This Been Tested?**: <!-- Please describe the tests that you ran to verify your changes. Provide output from the tests and any manual steps needed to replicate the tests. --> **Special notes for your reviewer**: <!-- Use this to provide any additional information to the reviewers. This may include: - Best way to review the PR. - Where the author wants the most review attention on. - etc. -->
1 parent 9c71eb0 commit e5d585a

File tree

10 files changed

+62
-65
lines changed

10 files changed

+62
-65
lines changed

pkg/webhook/preflight/generic/registry_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,10 @@ func TestRegistryCheck(t *testing.T) {
300300
InternalError: false,
301301
Causes: []preflight.Cause{
302302
{
303-
Message: fmt.Sprintf("Failed to parse registry URL %q with error: "+
304-
"parse \"invalid-url\": invalid URI for request", "invalid-url"),
303+
Message: fmt.Sprintf(
304+
"Failed to parse registry URL %q with error: parse \"invalid-url\": invalid URI for request",
305+
"invalid-url",
306+
),
305307
Field: "cluster.spec.topology.variables[.name=clusterConfig].value.imageRegistries[0].url",
306308
},
307309
},

pkg/webhook/preflight/generic/spec_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,9 @@ func TestNewConfigurationCheck(t *testing.T) {
106106
InternalError: true,
107107
Causes: []preflight.Cause{
108108
{
109-
Message: "Failed to unmarshal cluster variable clusterConfig: failed to unmarshal json:" +
110-
" invalid character 'i' looking for beginning of object key string",
111-
Field: "cluster.spec.topology.variables[.name=clusterConfig].genericClusterConfigSpec",
109+
///nolint:lll // The message is long.
110+
Message: "Failed to unmarshal cluster variable clusterConfig: failed to unmarshal json: invalid character 'i' looking for beginning of object key string",
111+
Field: "cluster.spec.topology.variables[.name=clusterConfig].genericClusterConfigSpec",
112112
},
113113
},
114114
},

pkg/webhook/preflight/nutanix/credentials.go

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,7 @@ func newCredentialsCheck(
7373
credentialsCheck.result.Causes = append(credentialsCheck.result.Causes,
7474
preflight.Cause{
7575
Message: fmt.Sprintf("Failed to parse Prism Central endpoint URL: %s", err),
76-
Field: "$.spec.topology.variables[[email protected]==\"clusterConfig\"]" +
77-
".value.nutanix.prismCentralEndpoint.url",
76+
Field: "$.spec.topology.variables[[email protected]==\"clusterConfig\"].value.nutanix.prismCentralEndpoint.url", ///nolint:lll // Field is long.
7877
},
7978
)
8079
return credentialsCheck
@@ -96,8 +95,7 @@ func newCredentialsCheck(
9695
preflight.Cause{
9796
Message: fmt.Sprintf("Prism Central credentials Secret %q not found",
9897
prismCentralEndpointSpec.Credentials.SecretRef.Name),
99-
Field: "$.spec.topology.variables[[email protected]==\"clusterConfig\"]" +
100-
".value.nutanix.prismCentralEndpoint.credentials.secretRef",
98+
Field: "$.spec.topology.variables[[email protected]==\"clusterConfig\"].value.nutanix.prismCentralEndpoint.credentials.secretRef", ///nolint:lll // Field is long.
10199
},
102100
)
103101
return credentialsCheck
@@ -111,8 +109,7 @@ func newCredentialsCheck(
111109
prismCentralEndpointSpec.Credentials.SecretRef.Name,
112110
err,
113111
),
114-
Field: "$.spec.topology.variables[[email protected]==\"clusterConfig\"]" +
115-
".value.nutanix.prismCentralEndpoint.credentials.secretRef",
112+
Field: "$.spec.topology.variables[[email protected]==\"clusterConfig\"].value.nutanix.prismCentralEndpoint.credentials.secretRef", ///nolint:lll // Field is long.
116113
},
117114
)
118115
return credentialsCheck
@@ -126,8 +123,7 @@ func newCredentialsCheck(
126123
"Credentials Secret %q is empty",
127124
prismCentralEndpointSpec.Credentials.SecretRef.Name,
128125
),
129-
Field: "$.spec.topology.variables[[email protected]==\"clusterConfig\"]" +
130-
".value.nutanix.prismCentralEndpoint.credentials.secretRef",
126+
Field: "$.spec.topology.variables[[email protected]==\"clusterConfig\"].value.nutanix.prismCentralEndpoint.credentials.secretRef", ///nolint:lll // Field is long.
131127
},
132128
)
133129
return credentialsCheck
@@ -143,8 +139,7 @@ func newCredentialsCheck(
143139
prismCentralEndpointSpec.Credentials.SecretRef.Name,
144140
credentialsSecretDataKey,
145141
),
146-
Field: "$.spec.topology.variables[[email protected]==\"clusterConfig\"]" +
147-
".value.nutanix.prismCentralEndpoint.credentials.secretRef",
142+
Field: "$.spec.topology.variables[[email protected]==\"clusterConfig\"].value.nutanix.prismCentralEndpoint.credentials.secretRef", ///nolint:lll // Field is long.
148143
},
149144
)
150145
return credentialsCheck
@@ -156,8 +151,7 @@ func newCredentialsCheck(
156151
credentialsCheck.result.Causes = append(credentialsCheck.result.Causes,
157152
preflight.Cause{
158153
Message: fmt.Sprintf("Failed to parse Prism Central credentials: %s", err),
159-
Field: "$.spec.topology.variables[[email protected]==\"clusterConfig\"]" +
160-
".value.nutanix.prismCentralEndpoint.credentials.secretRef",
154+
Field: "$.spec.topology.variables[[email protected]==\"clusterConfig\"].value.nutanix.prismCentralEndpoint.credentials.secretRef", ///nolint:lll // Field is long.
161155
},
162156
)
163157
return credentialsCheck
@@ -180,8 +174,7 @@ func newCredentialsCheck(
180174
credentialsCheck.result.Causes = append(credentialsCheck.result.Causes,
181175
preflight.Cause{
182176
Message: fmt.Sprintf("Failed to initialize Nutanix client: %s", err),
183-
Field: "$.spec.topology.variables[[email protected]==\"clusterConfig\"]" +
184-
".value.nutanix.prismCentralEndpoint.credentials.secretRef",
177+
Field: "$.spec.topology.variables[[email protected]==\"clusterConfig\"].value.nutanix.prismCentralEndpoint.credentials.secretRef", ///nolint:lll // Field is long.
185178
},
186179
)
187180
return credentialsCheck
@@ -200,8 +193,7 @@ func newCredentialsCheck(
200193
credentialsCheck.result.Causes = append(credentialsCheck.result.Causes,
201194
preflight.Cause{
202195
Message: fmt.Sprintf("Failed to validate credentials using the v3 API client: %s", err),
203-
Field: "$.spec.topology.variables[[email protected]==\"clusterConfig\"]" +
204-
".value.nutanix.prismCentralEndpoint.credentials.secretRef",
196+
Field: "$.spec.topology.variables[[email protected]==\"clusterConfig\"].value.nutanix.prismCentralEndpoint.credentials.secretRef", ///nolint:lll // Field is long.
205197
},
206198
)
207199
return credentialsCheck

pkg/webhook/preflight/nutanix/image.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,8 @@ func newVMImageChecks(
8282
checks = append(checks,
8383
&imageCheck{
8484
machineDetails: &cd.nutanixClusterConfigSpec.ControlPlane.Nutanix.MachineDetails,
85-
field: "$.spec.topology.variables[[email protected]==\"clusterConfig\"]." +
86-
".value.nutanix.controlPlane.machineDetails",
87-
nclient: cd.nclient,
85+
field: "$.spec.topology.variables[[email protected]==\"clusterConfig\"].value.nutanix.controlPlane.machineDetails", ///nolint:lll // Field is long.
86+
nclient: cd.nclient,
8887
},
8988
)
9089
}
@@ -94,8 +93,11 @@ func newVMImageChecks(
9493
checks = append(checks,
9594
&imageCheck{
9695
machineDetails: &nutanixWorkerNodeConfigSpec.Nutanix.MachineDetails,
97-
field: fmt.Sprintf("$.spec.topology.workers.machineDeployments[[email protected]==%q]"+
98-
".variables[[email protected]=workerConfig].value.nutanix.machineDetails", mdName),
96+
///nolint:lll // The field is long.
97+
field: fmt.Sprintf(
98+
"$.spec.topology.workers.machineDeployments[[email protected]==%q].variables[[email protected]=workerConfig].value.nutanix.machineDetails",
99+
mdName,
100+
),
99101
nclient: cd.nclient,
100102
},
101103
)

pkg/webhook/preflight/nutanix/imagekubernetesversioncheck.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,8 @@ func newVMImageKubernetesVersionChecks(
125125
cd.nutanixClusterConfigSpec.ControlPlane.Nutanix != nil {
126126
checks = append(checks,
127127
&imageKubernetesVersionCheck{
128-
machineDetails: &cd.nutanixClusterConfigSpec.ControlPlane.Nutanix.MachineDetails,
129-
field: "$.spec.topology.variables[[email protected]==\"clusterConfig\"]." +
130-
".value.nutanix.controlPlane.machineDetails",
128+
machineDetails: &cd.nutanixClusterConfigSpec.ControlPlane.Nutanix.MachineDetails,
129+
field: "$.spec.topology.variables[[email protected]==\"clusterConfig\"].value.nutanix.controlPlane.machineDetails", ///nolint:lll // Field is long.
131130
nclient: cd.nclient,
132131
clusterK8sVersion: clusterK8sVersion,
133132
},
@@ -139,8 +138,11 @@ func newVMImageKubernetesVersionChecks(
139138
checks = append(checks,
140139
&imageKubernetesVersionCheck{
141140
machineDetails: &nutanixWorkerNodeConfigSpec.Nutanix.MachineDetails,
142-
field: fmt.Sprintf("$.spec.topology.workers.machineDeployments[[email protected]==%q]"+
143-
".variables[[email protected]=workerConfig].value.nutanix.machineDetails", mdName),
141+
//nolint:lll // The field is long.
142+
field: fmt.Sprintf(
143+
"$.spec.topology.workers.machineDeployments[[email protected]==%q].variables[[email protected]=workerConfig].value.nutanix.machineDetails",
144+
mdName,
145+
),
144146
nclient: cd.nclient,
145147
clusterK8sVersion: clusterK8sVersion,
146148
},

pkg/webhook/preflight/nutanix/imagekubernetesversioncheck_test.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ func TestVMImageCheckWithKubernetesVersion(t *testing.T) {
7979
InternalError: false,
8080
Causes: []preflight.Cause{
8181
{
82-
Message: "Kubernetes version check failed: kubernetes version \"1.32.3\" is not part " +
83-
"of image name \"kubedistro-ubuntu-22.04-vgpu-1.31.5-20250604180644\"",
84-
Field: "machineDetails.image",
82+
///nolint:lll // The message is long.
83+
Message: "Kubernetes version check failed: kubernetes version \"1.32.3\" is not part of image name \"kubedistro-ubuntu-22.04-vgpu-1.31.5-20250604180644\"",
84+
Field: "machineDetails.image",
8585
},
8686
},
8787
},
@@ -137,9 +137,9 @@ func TestVMImageCheckWithKubernetesVersion(t *testing.T) {
137137
InternalError: false,
138138
Causes: []preflight.Cause{
139139
{
140-
Message: "Kubernetes version check failed: kubernetes version \"1.32.3\" is not part of " +
141-
"image name \"my-custom-image-name\"",
142-
Field: "machineDetails.image",
140+
///nolint:lll // The message is long.
141+
Message: "Kubernetes version check failed: kubernetes version \"1.32.3\" is not part of image name \"my-custom-image-name\"",
142+
Field: "machineDetails.image",
143143
},
144144
},
145145
},
@@ -170,9 +170,9 @@ func TestVMImageCheckWithKubernetesVersion(t *testing.T) {
170170
InternalError: false,
171171
Causes: []preflight.Cause{
172172
{
173-
Message: "Kubernetes version check failed: failed to parse kubernetes version " +
174-
"\"invalid.version\": No Major.Minor.Patch elements found",
175-
Field: "machineDetails.image",
173+
//nolint:lll // The message is long.
174+
Message: "Kubernetes version check failed: failed to parse kubernetes version \"invalid.version\": No Major.Minor.Patch elements found",
175+
Field: "machineDetails.image",
176176
},
177177
},
178178
},

pkg/webhook/preflight/nutanix/specs.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ func newConfigurationCheck(
8686
carenv1.WorkerConfigVariableName,
8787
err,
8888
),
89+
//nolint:lll // The field is long.
8990
Field: fmt.Sprintf(
90-
"$.spec.topology.workers.machineDeployments[[email protected]==%q]"+
91-
".variables[[email protected]=workerConfig].value.nutanix.machineDetails",
91+
"$.spec.topology.workers.machineDeployments[[email protected]==%q].variables[[email protected]=workerConfig].value.nutanix.machineDetails",
9292
md.Name,
9393
),
9494
},

pkg/webhook/preflight/nutanix/specs_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,9 @@ func TestNewConfigurationCheck(t *testing.T) {
136136
InternalError: true,
137137
Causes: []preflight.Cause{
138138
{
139-
Message: "Failed to unmarshal cluster variable clusterConfig: failed to unmarshal json:" +
140-
" invalid character 'i' looking for beginning of object key string",
141-
Field: "$.spec.topology.variables[[email protected]==\"clusterConfig\"].value.nutanix",
139+
//nolint:lll // The message is long.
140+
Message: "Failed to unmarshal cluster variable clusterConfig: failed to unmarshal json: invalid character 'i' looking for beginning of object key string",
141+
Field: "$.spec.topology.variables[[email protected]==\"clusterConfig\"].value.nutanix",
142142
},
143143
},
144144
},
@@ -184,10 +184,10 @@ func TestNewConfigurationCheck(t *testing.T) {
184184
InternalError: true,
185185
Causes: []preflight.Cause{
186186
{
187-
Message: "Failed to unmarshal topology machineDeployment variable workerConfig:" +
188-
" failed to unmarshal json: invalid character 'i' looking for beginning of object key string",
189-
Field: "$.spec.topology.workers.machineDeployments[[email protected]==\"md-0\"]" +
190-
".variables[[email protected]=workerConfig].value.nutanix.machineDetails",
187+
//nolint:lll // The message is long.
188+
Message: "Failed to unmarshal topology machineDeployment variable workerConfig: failed to unmarshal json: invalid character 'i' looking for beginning of object key string",
189+
//nolint:lll // The field is long.
190+
Field: "$.spec.topology.workers.machineDeployments[[email protected]==\"md-0\"].variables[[email protected]=workerConfig].value.nutanix.machineDetails",
191191
},
192192
},
193193
},

pkg/webhook/preflight/nutanix/storagecontainer.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,9 @@ func newStorageContainerChecks(cd *checkDependencies) []preflight.Check {
162162
checks = append(checks,
163163
&storageContainerCheck{
164164
machineSpec: &nutanixWorkerNodeConfigSpec.Nutanix.MachineDetails,
165+
//nolint:lll // The field is long.
165166
field: fmt.Sprintf(
166-
"$.spec.topology.workers.machineDeployments[[email protected]==%q]"+
167-
".variables[[email protected]=workerConfig].value.nutanix.machineDetails",
167+
"$.spec.topology.workers.machineDeployments[[email protected]==%q].variables[[email protected]=workerConfig].value.nutanix.machineDetails",
168168
mdName,
169169
),
170170
csiSpec: &cd.nutanixClusterConfigSpec.Addons.CSI.Providers.NutanixCSI,
@@ -193,7 +193,7 @@ func getStorageContainers(
193193
}
194194
containers, ok := resp.GetData().([]clustermgmtv4.StorageContainer)
195195
if !ok {
196-
return nil, fmt.Errorf("failed to get data returned by ListStorageContainers(filter=%q)", fltr)
196+
return nil, fmt.Errorf("failed to get data returned by ListStorageContainers (filter=%q)", fltr)
197197
}
198198
return containers, nil
199199
}

pkg/webhook/preflight/nutanix/storagecontainer_test.go

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -384,8 +384,8 @@ func TestStorageContainerCheck(t *testing.T) {
384384
},
385385
expectedAllowed: false,
386386
expectedError: false,
387-
expectedCauseMessage: "Expected to find 1 storage container named \"missing-container\" " +
388-
"on cluster \"test-cluster\", found 0",
387+
//nolint:lll // The message is long.
388+
expectedCauseMessage: "Expected to find 1 storage container named \"missing-container\" on cluster \"test-cluster\", found 0",
389389
},
390390
{
391391
name: "multiple storage containers found",
@@ -460,8 +460,8 @@ func TestStorageContainerCheck(t *testing.T) {
460460
},
461461
expectedAllowed: false,
462462
expectedError: false,
463-
expectedCauseMessage: "Expected to find 1 storage container named \"duplicate-container\" " +
464-
"on cluster \"test-cluster\", found 2",
463+
//nolint:lll // The message is long.
464+
expectedCauseMessage: "Expected to find 1 storage container named \"duplicate-container\" on cluster \"test-cluster\", found 2",
465465
},
466466
{
467467
name: "successful storage container check",
@@ -623,8 +623,8 @@ func TestStorageContainerCheck(t *testing.T) {
623623
},
624624
expectedAllowed: false,
625625
expectedError: true,
626-
expectedCauseMessage: "Failed to check if storage container \"valid-container\" exists: " +
627-
"failed to get cluster \"test-cluster\": API error",
626+
//nolint:lll // The message is long.
627+
expectedCauseMessage: "Failed to check if storage container \"valid-container\" exists: failed to get cluster \"test-cluster\": API error",
628628
},
629629
{
630630
name: "error listing storage containers",
@@ -687,8 +687,8 @@ func TestStorageContainerCheck(t *testing.T) {
687687
},
688688
expectedAllowed: false,
689689
expectedError: true,
690-
expectedCauseMessage: "Failed to check if storage container \"valid-container\" exists in cluster " +
691-
"\"test-cluster\": API error listing containers",
690+
//nolint:lll // The message is long.
691+
expectedCauseMessage: "Failed to check if storage container \"valid-container\" exists in cluster \"test-cluster\": API error listing containers",
692692
},
693693
{
694694
name: "error response from ListStorageContainers",
@@ -754,9 +754,8 @@ func TestStorageContainerCheck(t *testing.T) {
754754
},
755755
expectedAllowed: false,
756756
expectedError: true,
757-
expectedCauseMessage: "Failed to check if storage container \"valid-container\" exists in cluster " +
758-
"\"test-cluster\": failed to get data returned by ListStorageContainers" +
759-
"(filter=\"name eq 'valid-container' and clusterExtId eq 'cluster-uuid-123'\")",
757+
//nolint:lll // The message is long.
758+
expectedCauseMessage: "Failed to check if storage container \"valid-container\" exists in cluster \"test-cluster\": failed to get data returned by ListStorageContainers (filter=\"name eq 'valid-container' and clusterExtId eq 'cluster-uuid-123'\")",
760759
},
761760
{
762761
name: "nil data from ListStorageContainers",
@@ -819,8 +818,8 @@ func TestStorageContainerCheck(t *testing.T) {
819818
},
820819
expectedAllowed: false,
821820
expectedError: false,
822-
expectedCauseMessage: "Expected to find 1 storage container named \"valid-container\" " +
823-
"on cluster \"test-cluster\", found 0",
821+
//nolint:lll // The message is long.
822+
expectedCauseMessage: "Expected to find 1 storage container named \"valid-container\" on cluster \"test-cluster\", found 0",
824823
},
825824
{
826825
name: "multiple storage class configs with success",

0 commit comments

Comments
 (0)