8000 Reverse order of XValidations when flattening · kubernetes-sigs/controller-tools@43d3d3a · GitHub
[go: up one dir, main page]

Skip to content

Commit 43d3d3a

Browse files
committed
Reverse order of XValidations when flattening
1 parent 4361106 commit 43d3d3a

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

pkg/crd/flatten.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ func flattenAllOfInto(dst *apiext.JSONSchemaProps, src apiext.JSONSchemaProps, e
148148
case "XMapType":
149149
dstField.Set(srcField)
150150
case "XValidations":
151-
dstField.Set(reflect.AppendSlice(dstField, srcField))
151+
dstField.Set(reflect.AppendSlice(srcField, dstField))
152152
// NB(directxman12): no need to explicitly handle nullable -- false is considered to be the zero value
153153
// TODO(directxman12): src isn't necessarily the field value -- it's just the most recent allOf entry
154154
default:

pkg/crd/flatten_all_of_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDi 8000 ff line numberDiff line change
@@ -246,8 +246,8 @@ var _ = Describe("AllOf Flattening", func() {
246246
By("flattening a schema with multiple validation fields")
247247
original := &apiext.JSONSchemaProps{
248248
AllOf: []apiext.JSONSchemaProps{
249-
{XValidations: apiext.ValidationRules{{Rule: "rule1"}, {Rule: "rule2"}}},
250-
{XValidations: apiext.ValidationRules{{Rule: "rule3"}}},
249+
{XValidations: apiext.ValidationRules{{Rule: "rule2"}, {Rule: "rule3"}}},
250+
{XValidations: apiext.ValidationRules{{Rule: "rule1"}}},
251251
},
252252
}
253253
flattened := crd.FlattenEmbedded(original, errRec)

pkg/crd/testdata/testdata.kubebuilder.io_cronjobs.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6845,10 +6845,10 @@ spec:
68456845
and type.
68466846
type: string
68476847
x-kubernetes-validations:
6848-
- message: must have even length
6849-
rule: self.size() % 2 == 0
68506848
- message: must have good prefix
68516849
rule: self.startsWith('good-')
6850+
- message: must have even length
6851+
rule: self.size() % 2 == 0
68526852
structWithSeveralFields:
68536853
description: A struct that can only be entirely replaced
68546854
properties:

0 commit comments

Comments
 (0)
0