Skip to content

Commit

Permalink
pass deref'd pointer to ValidateCustomResource to dodge false incompa…
Browse files Browse the repository at this point in the history
…tibility notice

Signed-off-by: Jordan Keister <[email protected]>
  • Loading branch information
grokspawn committed Dec 5, 2024
1 parent 1474ee3 commit f32f49b
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions pkg/controller/operators/catalog/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -2242,15 +2242,16 @@ func validateExistingCRs(dynamicClient dynamic.Interface, gr schema.GroupResourc
return fmt.Errorf("error creating validator for schema version %s: %s", version, err)
}
gvr := schema.GroupVersionResource{Group: gr.Group, Version: version, Resource: gr.Resource}

pager := pager.New(pager.SimplePageFunc(func(opts metav1.ListOptions) (runtime.Object, error) {
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, 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

0 comments on commit f32f49b

Please sign in to comment.