Skip to content

Commit 7f928a3

Browse files
Merge pull request #9615 from zaneb/path-case
OCPBUGS-54407: Use correct case in path error messages
2 parents 5a9cd87 + 82b500b commit 7f928a3

26 files changed

+183
-176
lines changed

cmd/openshift-install/testdata/agent/image/validations/compact_invalid_controlPlane_replicas.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
! exec openshift-install agent create image --dir $WORK
22

3-
stderr 'ControlPlane.Replicas can only be set to 5, 4, 3, or 1. Found 2'
3+
stderr 'controlPlane.replicas: Unsupported value: 2: supported values: "3", "1", "4", "5"'
44

55
! exists $WORK/agent.x86_64.iso
66
! exists $WORK/auth/kubeconfig
@@ -39,4 +39,4 @@ apiVersion: v1alpha1
3939
metadata:
4040
name: ostest
4141
namespace: cluster0
42-
rendezvousIP: 192.168.111.20
42+
rendezvousIP: 192.168.111.20

cmd/openshift-install/testdata/agent/image/validations/sno_invalid_workers.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
! exec openshift-install agent create image --dir $WORK
22

3-
stderr 'Total number of Compute.Replicas must be 0 when ControlPlane.Replicas is 1 for platform none or external. Found 1'
3+
stderr 'Total number of compute replicas must be 0 when controlPlane.replicas is 1 for platform none or external. Found 1'
44

55
! exists $WORK/agent.x86_64.iso
66
! exists $WORK/auth/kubeconfig
@@ -37,4 +37,4 @@ apiVersion: v1alpha1
3737
metadata:
3838
name: ostest
3939
namespace: cluster0
40-
rendezvousIP: 192.168.111.20
40+
rendezvousIP: 192.168.111.20

cmd/openshift-install/testdata/agent/image/validations/vsphere_with-partial-credentials.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
! exec openshift-install agent create image --dir $WORK
22

33
stderr 'Invalid value: "diff.openshift.com": server does not exist in vcenters'
4-
stderr 'Platform.VSphere.failureDomains.topology.folder: Required value: must specify a folder for agent-based installs'
4+
stderr 'platform.vsphere.failureDomains\[0\].topology.folder: Required value: must specify a folder for agent-based installs'
55

66
! exists $WORK/agent.x86_64.iso
77
! exists $WORK/auth/kubeconfig

pkg/asset/agent/agentconfig/agent_config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ func (a *AgentConfig) validateAgent() field.ErrorList {
168168
allErrs = append(allErrs, err...)
169169
}
170170

171-
if err := validation.ValidateNTPServers(a.Config.AdditionalNTPSources, field.NewPath("AdditionalNTPSources")); err != nil {
171+
if err := validation.ValidateNTPServers(a.Config.AdditionalNTPSources, field.NewPath("additionalNTPSources")); err != nil {
172172
allErrs = append(allErrs, err...)
173173
}
174174

pkg/asset/agent/agentconfig/agent_config_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ additionalNTPSources:
123123
- invalid_pool.ntp.org
124124
rendezvousIP: 192.168.111.80`,
125125
expectedFound: false,
126-
expectedError: "invalid Agent Config configuration: AdditionalNTPSources: Invalid value: \"invalid_pool.ntp.org\": NTP server is not a valid IP or domain name",
126+
expectedError: "invalid Agent Config configuration: additionalNTPSources: Invalid value: \"invalid_pool.ntp.org\": NTP server is not a valid IP or domain name",
127127
},
128128
}
129129
for _, tc := range cases {

pkg/asset/agent/agentconfig/agenthosts.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ func (a *AgentHosts) validateAgentHosts() field.ErrorList {
122122

123123
macs := make(map[string]bool)
124124
for i, host := range a.Hosts {
125-
hostPath := field.NewPath("Hosts").Index(i)
125+
hostPath := field.NewPath("hosts").Index(i)
126126

127127
if err := a.validateHostInterfaces(hostPath, host, macs); err != nil {
128128
allErrs = append(allErrs, err...)
@@ -147,7 +147,7 @@ func (a *AgentHosts) validateAgentHosts() field.ErrorList {
147147
func (a *AgentHosts) validateHostInterfaces(hostPath *field.Path, host agent.Host, macs map[string]bool) field.ErrorList {
148148
var allErrs field.ErrorList
149149

150-
interfacePath := hostPath.Child("Interfaces")
150+
interfacePath := hostPath.Child("interfaces")
151151
if len(host.Interfaces) == 0 {
152152
allErrs = append(allErrs, field.Required(interfacePath, "at least one interface must be defined for each node"))
153153
}
@@ -194,7 +194,8 @@ func (a *AgentHosts) validateRoles(hostPath *field.Path, host agent.Host) field.
194194
var allErrs field.ErrorList
195195

196196
if len(host.Role) > 0 && host.Role != masterRole && host.Role != workerRole {
197-
allErrs = append(allErrs, field.Forbidden(hostPath.Child("Host"), "host role has incorrect value. Role must either be 'master' or 'worker'"))
197+
allErrs = append(allErrs, field.NotSupported(hostPath.Child("role"), host.Role,
198+
[]string{masterRole, workerRole}))
198199
}
199200

200201
return allErrs
@@ -208,7 +209,7 @@ func (a *AgentHosts) validateRendezvousIPNotWorker(rendezvousIP string, hosts []
208209
if host.Role != workerRole {
209210
continue
210211
}
211-
hostPath := field.NewPath("Hosts").Index(i)
212+
hostPath := field.NewPath("hosts").Index(i)
212213
hostIPs, err := agentAsset.GetAllHostIPs(host.NetworkConfig)
213214
if err != nil {
214215
allErrs = append(allErrs, field.Invalid(hostPath, host.NetworkConfig, err.Error()))
@@ -217,7 +218,7 @@ func (a *AgentHosts) validateRendezvousIPNotWorker(rendezvousIP string, hosts []
217218
_, found := hostIPs[rendezvousIP]
218219
if found {
219220
errMsg := "Host " + host.Hostname + " has role 'worker' and has the rendezvousIP assigned to it. The rendezvousIP must be assigned to a control plane host."
220-
allErrs = append(allErrs, field.Forbidden(hostPath.Child("Host"), errMsg))
221+
allErrs = append(allErrs, field.Forbidden(hostPath.Child("role"), errMsg))
221222
}
222223
}
223224
}

pkg/asset/agent/agentconfig/agenthosts_test.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ func TestAgentHosts_Generate(t *testing.T) {
197197
getInstallConfigSingleHost(),
198198
getAgentConfigUnsupportedDeviceName(),
199199
},
200-
expectedError: "invalid Hosts configuration: Hosts[0].rootDeviceHints.deviceName: Invalid value: \"/dev/disk/by-id/wwn-0x600508e000000000ce506dc50ab0ad05\": Device Name of root device hint must be path in /dev/ or /dev/disk/by-path/",
200+
expectedError: "invalid Hosts configuration: hosts[0].rootDeviceHints.deviceName: Invalid value: \"/dev/disk/by-id/wwn-0x600508e000000000ce506dc50ab0ad05\": Device Name of root device hint must be path in /dev/ or /dev/disk/by-path/",
201201
expectedConfig: nil,
202202
},
203203
{
@@ -208,7 +208,7 @@ func TestAgentHosts_Generate(t *testing.T) {
208208
getInstallConfigUnsupportedWWNExtension(),
209209
getNoHostsAgentConfig(),
210210
},
211-
expectedError: "invalid Hosts configuration: Hosts[0].rootDeviceHints.wwnWithExtension: Forbidden: WWN extensions are not supported in root device hints",
211+
expectedError: "invalid Hosts configuration: hosts[0].rootDeviceHints.wwnWithExtension: Forbidden: WWN extensions are not supported in root device hints",
212212
expectedConfig: nil,
213213
},
214214
{
@@ -219,7 +219,7 @@ func TestAgentHosts_Generate(t *testing.T) {
219219
getInstallConfigSingleHost(),
220220
getAgentConfigUnsupportedWWNVendorExtension(),
221221
},
222-
expectedError: "invalid Hosts configuration: Hosts[0].rootDeviceHints.wwnVendorExtension: Forbidden: WWN vendor extensions are not supported in root device hints",
222+
expectedError: "invalid Hosts configuration: hosts[0].rootDeviceHints.wwnVendorExtension: Forbidden: WWN vendor extensions are not supported in root device hints",
223223
expectedConfig: nil,
224224
},
225225
{
@@ -240,7 +240,7 @@ func TestAgentHosts_Generate(t *testing.T) {
240240
getInstallConfigSingleHost(),
241241
getAgentConfigInvalidHostRole(),
242242
},
243-
expectedError: "invalid Hosts configuration: Hosts[0].Host: Forbidden: host role has incorrect value. Role must either be 'master' or 'worker'",
243+
expectedError: "invalid Hosts configuration: hosts[0].role: Unsupported value: \"invalid-role\": supported values: \"master\", \"worker\"",
244244
expectedConfig: nil,
245245
},
246246
{
@@ -251,7 +251,7 @@ func TestAgentHosts_Generate(t *testing.T) {
251251
getInstallConfigSameMac(),
252252
getNoHostsAgentConfig(),
253253
},
254-
expectedError: "invalid Hosts configuration: Hosts[1].Interfaces[0].macAddress: Invalid value: \"28:d2:44:b0:bf:01\": duplicate MAC address found",
254+
expectedError: "invalid Hosts configuration: hosts[1].interfaces[0].macAddress: Invalid value: \"28:d2:44:b0:bf:01\": duplicate MAC address found",
255255
expectedConfig: nil,
256256
},
257257
{
@@ -262,7 +262,7 @@ func TestAgentHosts_Generate(t *testing.T) {
262262
getInstallConfigSingleHost(),
263263
getAgentConfigInvalidMac(),
264264
},
265-
expectedError: "invalid Hosts configuration: Hosts[0].Interfaces[0].macAddress: Invalid value: \"000000\": address 000000: invalid MAC address",
265+
expectedError: "invalid Hosts configuration: hosts[0].interfaces[0].macAddress: Invalid value: \"000000\": address 000000: invalid MAC address",
266266
expectedConfig: nil,
267267
},
268268
{
@@ -273,7 +273,7 @@ func TestAgentHosts_Generate(t *testing.T) {
273273
getInstallConfigSingleHost(),
274274
getAgentConfigInvalidInterfaces(),
275275
},
276-
expectedError: "invalid Hosts configuration: Hosts[0].Interfaces[1].macAddress: Invalid value: \"28:d2:44:d2:b2:1a\": duplicate MAC address found",
276+
expectedError: "invalid Hosts configuration: hosts[0].interfaces[1].macAddress: Invalid value: \"28:d2:44:d2:b2:1a\": duplicate MAC address found",
277277
expectedConfig: nil,
278278
},
279279
{
@@ -284,7 +284,7 @@ func TestAgentHosts_Generate(t *testing.T) {
284284
getInstallConfigInvalidInterfaces(),
285285
getNoHostsAgentConfig(),
286286
},
287-
expectedError: "invalid Hosts configuration: Hosts[0].Interfaces[1].macAddress: Invalid value: \"28:d2:44:b0:bf:01\": duplicate MAC address found",
287+
expectedError: "invalid Hosts configuration: hosts[0].interfaces[1].macAddress: Invalid value: \"28:d2:44:b0:bf:01\": duplicate MAC address found",
288288
expectedConfig: nil,
289289
},
290290
{
@@ -295,7 +295,7 @@ func TestAgentHosts_Generate(t *testing.T) {
295295
getInstallConfigSingleHost(),
296296
getAgentConfigInvalidRendezvousIP(),
297297
},
298-
expectedError: "invalid Hosts configuration: Hosts[1].Host: Forbidden: Host test-2 has role 'worker' and has the rendezvousIP assigned to it. The rendezvousIP must be assigned to a control plane host.",
298+
expectedError: "invalid Hosts configuration: hosts[1].role: Forbidden: Host test-2 has role 'worker' and has the rendezvousIP assigned to it. The rendezvousIP must be assigned to a control plane host.",
299299
expectedConfig: nil,
300300
},
301301
{
@@ -306,7 +306,7 @@ func TestAgentHosts_Generate(t *testing.T) {
306306
getInstallConfigInvalidRendezvousIP(),
307307
getNoHostsAgentConfig(),
308308
},
309-
expectedError: "invalid Hosts configuration: Hosts[0].Host: Forbidden: Host test has role 'worker' and has the rendezvousIP assigned to it. The rendezvousIP must be assigned to a control plane host.",
309+
expectedError: "invalid Hosts configuration: hosts[0].role: Forbidden: Host test has role 'worker' and has the rendezvousIP assigned to it. The rendezvousIP must be assigned to a control plane host.",
310310
expectedConfig: nil,
311311
},
312312
{
@@ -317,7 +317,7 @@ func TestAgentHosts_Generate(t *testing.T) {
317317
getInstallConfigSingleHost(),
318318
getAgentConfigMissingInterfaces(),
319319
},
320-
expectedError: "invalid Hosts configuration: [Hosts[0].Interfaces: Required value: at least one interface must be defined for each node, Hosts[1].Interfaces: Required value: at least one interface must be defined for each node, Hosts[2].Interfaces: Required value: at least one interface must be defined for each node]",
320+
expectedError: "invalid Hosts configuration: [hosts[0].interfaces: Required value: at least one interface must be defined for each node, hosts[1].interfaces: Required value: at least one interface must be defined for each node, hosts[2].interfaces: Required value: at least one interface must be defined for each node]",
321321
expectedConfig: nil,
322322
},
323323
{

0 commit comments

Comments
 (0)