Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2220,11 +2220,11 @@ func validateExistingCRs(dynamicClient dynamic.Interface, gr schema.GroupResourc
return dynamicClient.Resource(gvr).List(context.TODO(), opts)
}))
validationFn := func(obj runtime.Object) error {
err = validation.ValidateCustomResource(field.NewPath(""), obj, validator).ToAggregate()
// lister will only provide unstructured objects as runtime.Object, so this should never fail to convert
// if it does, it's a programming error
cr := obj.(*unstructured.Unstructured)
err = validation.ValidateCustomResource(field.NewPath(""), cr.UnstructuredContent(), validator).ToAggregate()
if err != nil {
// lister will only provide unstructured objects as runtime.Object, so this should never fail to convert
// if it does, it's a programming error
cr := obj.(*unstructured.Unstructured)
var namespacedName string
if cr.GetNamespace() == "" {
namespacedName = cr.GetName()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1835,6 +1835,14 @@ func TestValidateV1Beta1CRDCompatibility(t *testing.T) {
newCRD: unversionedCRDForV1beta1File("testdata/apiextensionsv1beta1/crd.no-versions-list.yaml"),
want: validationError{fmt.Errorf("error validating cluster.com/v1alpha1, Kind=testcrd \"my-cr-1\": updated validation is too restrictive: [].spec.scalar: Invalid value: 2: spec.scalar in body should be greater than or equal to 3")},
},
{
name: "crd with incorrect comparison",
existingObjects: []runtime.Object{
unstructuredForFile("testdata/postgrestolerations/pgadmin.cr.yaml"),
},
oldCRD: unversionedCRDForV1beta1File("testdata/postgrestolerations/crd.yaml"),
newCRD: unversionedCRDForV1beta1File("testdata/postgrestolerations/crd.yaml"),
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down
Loading