Skip to content

Commit 21b81fd

Browse files
committed
fix: Use correct field when unmarshal error happens
1 parent dc1ca85 commit 21b81fd

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

pkg/webhook/preflight/generic/spec.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func newConfigurationCheck(
5050
carenv1.ClusterConfigVariableName,
5151
err,
5252
),
53-
Field: "$.spec.topology.variables[[email protected]==\"clusterConfig\"].genericClusterConfigSpec",
53+
Field: "$.spec.topology.variables[[email protected]==\"clusterConfig\"]",
5454
},
5555
)
5656
}

pkg/webhook/preflight/generic/spec_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ func TestNewConfigurationCheck(t *testing.T) {
107107
Causes: []preflight.Cause{
108108
{
109109
Message: "Failed to unmarshal cluster variable \"clusterConfig\": failed to unmarshal json: invalid character 'i' looking for beginning of object key string. Review the Cluster.", ///nolint:lll // The message is long.
110-
Field: "$.spec.topology.variables[[email protected]==\"clusterConfig\"].genericClusterConfigSpec",
110+
Field: "$.spec.topology.variables[[email protected]==\"clusterConfig\"]",
111111
},
112112
},
113113
},

pkg/webhook/preflight/nutanix/specs.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func newConfigurationCheck(
5656
carenv1.ClusterConfigVariableName,
5757
err,
5858
),
59-
Field: "$.spec.topology.variables[[email protected]==\"clusterConfig\"].value.nutanix",
59+
Field: "$.spec.topology.variables[[email protected]==\"clusterConfig\"]",
6060
},
6161
)
6262
}
@@ -88,7 +88,7 @@ func newConfigurationCheck(
8888
)
8989
if workerConfigVar != nil {
9090
workerConfigFieldPath = fmt.Sprintf(
91-
"$.spec.topology.workers.machineDeployments[[email protected]==%q].variables[[email protected]=='%s'].value.nutanix",
91+
"$.spec.topology.workers.machineDeployments[[email protected]==%q].variables[[email protected]=='%s']",
9292
md.Name,
9393
carenv1.WorkerConfigVariableName,
9494
)
@@ -101,7 +101,7 @@ func newConfigurationCheck(
101101
)
102102
if workerConfigVar != nil {
103103
workerConfigFieldPath = fmt.Sprintf(
104-
"$.spec.topology.variables[[email protected]=='%s'].value.nutanix",
104+
"$.spec.topology.variables[[email protected]=='%s']",
105105
carenv1.WorkerConfigVariableName,
106106
)
107107
}

pkg/webhook/preflight/nutanix/specs_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ func TestNewConfigurationCheck(t *testing.T) {
138138
Causes: []preflight.Cause{
139139
{
140140
Message: "Failed to unmarshal cluster variable \"clusterConfig\": failed to unmarshal json: invalid character 'i' looking for beginning of object key string. Review the Cluster.", ///nolint:lll // The message is long.
141-
Field: "$.spec.topology.variables[[email protected]==\"clusterConfig\"].value.nutanix",
141+
Field: "$.spec.topology.variables[[email protected]==\"clusterConfig\"]",
142142
},
143143
},
144144
},
@@ -185,7 +185,7 @@ func TestNewConfigurationCheck(t *testing.T) {
185185
Causes: []preflight.Cause{
186186
{
187187
Message: "Failed to unmarshal variable \"workerConfig\": failed to unmarshal json: invalid character 'i' looking for beginning of object key string. Review the Cluster.", ///nolint:lll // The message is long.
188-
Field: "$.spec.topology.workers.machineDeployments[[email protected]==\"md-0\"].variables[[email protected]=='workerConfig'].value.nutanix", ///nolint:lll // The field is long.
188+
Field: "$.spec.topology.workers.machineDeployments[[email protected]==\"md-0\"].variables[[email protected]=='workerConfig']", ///nolint:lll // The field is long.
189189
},
190190
},
191191
},

0 commit comments

Comments
 (0)