Skip to content

Commit d7372a6

Browse files
committed
type assertion to force interface conversion
Signed-off-by: Jordan Keister <[email protected]>
1 parent b8d6d7b commit d7372a6

File tree

2 files changed

+8
-46
lines changed
  • staging/operator-lifecycle-manager/pkg/controller/operators/catalog
  • vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/controller/operators/catalog

2 files changed

+8
-46
lines changed

staging/operator-lifecycle-manager/pkg/controller/operators/catalog/operator.go

+4-23
Original file line numberDiff line numberDiff line change
@@ -2243,34 +2243,15 @@ func validateExistingCRs(dynamicClient dynamic.Interface, gr schema.GroupResourc
22432243
}
22442244
gvr := schema.GroupVersionResource{Group: gr.Group, Version: version, Resource: gr.Resource}
22452245

2246-
results := make(map[string]*unstructured.Unstructured)
2247-
2248-
crList, err := dynamicClient.Resource(gvr).List(context.TODO(), metav1.ListOptions{})
2249-
if err != nil {
2250-
return fmt.Errorf("error listing resources in GroupVersionResource %#v: %s", gvr, err)
2251-
}
2252-
for _, cr := range crList.Items {
2253-
var namespacedName string
2254-
if cr.GetNamespace() == "" {
2255-
namespacedName = cr.GetName()
2256-
} else {
2257-
namespacedName = fmt.Sprintf("%s/%s", cr.GetNamespace(), cr.GetName())
2258-
}
2259-
if err := validation.ValidateCustomResource(field.NewPath(""), &cr, validator).ToAggregate(); err != nil {
2260-
return validationError{fmt.Errorf("blocking lister: error validating %s %q: updated validation is too restrictive: %v", cr.GroupVersionKind(), namespacedName, err)}
2261-
}
2262-
results[namespacedName] = &cr
2263-
}
2264-
22652246
pager := pager.New(pager.SimplePageFunc(func(opts metav1.ListOptions) (runtime.Object, error) {
22662247
return dynamicClient.Resource(gvr).List(context.TODO(), opts)
22672248
}))
22682249
validationFn := func(obj runtime.Object) error {
2269-
err = validation.ValidateCustomResource(field.NewPath(""), obj, validator).ToAggregate()
2250+
// lister will only provide unstructured objects as runtime.Object, so this should never fail to convert
2251+
// if it does, it's a programming error
2252+
cr := obj.(*unstructured.Unstructured)
2253+
err = validation.ValidateCustomResource(field.NewPath(""), cr, validator).ToAggregate()
22702254
if err != nil {
2271-
// lister will only provide unstructured objects as runtime.Object, so this should never fail to convert
2272-
// if it does, it's a programming error
2273-
cr := obj.(*unstructured.Unstructured)
22742255
var namespacedName string
22752256
if cr.GetNamespace() == "" {
22762257
namespacedName = cr.GetName()

vendor/github.com/operator-framework/operator-lifecycle-manager/pkg/controller/operators/catalog/operator.go

+4-23
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)