From b362ca139b92e730bfb7b68fd614f3265ae3d23c Mon Sep 17 00:00:00 2001 From: Todd Short Date: Thu, 6 Jun 2024 15:50:54 -0400 Subject: [PATCH] Fix webhooks package name and remove unstructured Make the webhooks package name consistent with oterhs Revert the use of unstructured Signed-off-by: Todd Short --- Makefile | 2 +- .../clusterextension_controller.go | 22 +++++-------------- testdata/catalogs/test-catalog/catalog.yaml | 2 +- 3 files changed, 7 insertions(+), 19 deletions(-) diff --git a/Makefile b/Makefile index 9adce0d55..e32f6cb77 100644 --- a/Makefile +++ b/Makefile @@ -206,7 +206,7 @@ registry-load-bundles: ## Load selected e2e testdata container images created in testdata/bundles/registry-v1/build-push-e2e-bundle.sh ${E2E_REGISTRY_NAMESPACE} $(DNS_NAME):5000/bundles/registry-v1/prometheus-operator:v1.0.1 prometheus-operator.v1.0.1 prometheus-operator.v1.0.0 testdata/bundles/registry-v1/build-push-e2e-bundle.sh ${E2E_REGISTRY_NAMESPACE} $(DNS_NAME):5000/bundles/registry-v1/prometheus-operator:v1.2.0 prometheus-operator.v1.2.0 prometheus-operator.v1.0.0 testdata/bundles/registry-v1/build-push-e2e-bundle.sh ${E2E_REGISTRY_NAMESPACE} $(DNS_NAME):5000/bundles/registry-v1/prometheus-operator:v2.0.0 prometheus-operator.v2.0.0 prometheus-operator.v1.0.0 - testdata/bundles/registry-v1/build-push-e2e-bundle.sh ${E2E_REGISTRY_NAMESPACE} $(DNS_NAME):5000/bundles/registry-v1/prometheus-with-webhooks.v1.0.0 prometheus-with-webhooks.v1.0.0 package-with-webhooks.v1.0.0 + testdata/bundles/registry-v1/build-push-e2e-bundle.sh ${E2E_REGISTRY_NAMESPACE} $(DNS_NAME):5000/bundles/registry-v1/prometheus-with-webhooks:v1.0.0 prometheus-with-webhooks.v1.0.0 package-with-webhooks.v1.0.0 #SECTION Build diff --git a/internal/controllers/clusterextension_controller.go b/internal/controllers/clusterextension_controller.go index 6f64ed18f..e0a1e9a2b 100644 --- a/internal/controllers/clusterextension_controller.go +++ b/internal/controllers/clusterextension_controller.go @@ -41,7 +41,6 @@ import ( apimeta "k8s.io/apimachinery/pkg/api/meta" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/sets" @@ -332,28 +331,17 @@ func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alp } for _, obj := range relObjects { - uMap, err := runtime.DefaultUnstructuredConverter.ToUnstructured(obj) - if err != nil { - setInstalledStatusConditionFailed(ext, fmt.Sprintf("%s:%v", ocv1alpha1.ReasonCreateDynamicWatchFailed, err)) - return ctrl.Result{}, err - } - - unstructuredObj := &unstructured.Unstructured{Object: uMap} if err := func() error { r.dynamicWatchMutex.Lock() defer r.dynamicWatchMutex.Unlock() - _, isWatched := r.dynamicWatchGVKs[unstructuredObj.GroupVersionKind()] + _, isWatched := r.dynamicWatchGVKs[obj.GetObjectKind().GroupVersionKind()] if !isWatched { if err := r.controller.Watch( - source.Kind( - r.cache, unstructuredObj, crhandler.TypedEnqueueRequestForOwner[*unstructured.Unstructured]( - r.Scheme(), - r.RESTMapper(), - ext, - crhandler.OnlyControllerOwner(), - ), - helmpredicate.DependentPredicateFuncs[*unstructured.Unstructured](), + source.Kind(r.cache, + obj, + crhandler.EnqueueRequestForOwner(r.Scheme(), r.RESTMapper(), ext, crhandler.OnlyControllerOwner()), + helmpredicate.DependentPredicateFuncs[client.Object](), ), ); err != nil { return err diff --git a/testdata/catalogs/test-catalog/catalog.yaml b/testdata/catalogs/test-catalog/catalog.yaml index 33612c529..6830d15f2 100644 --- a/testdata/catalogs/test-catalog/catalog.yaml +++ b/testdata/catalogs/test-catalog/catalog.yaml @@ -74,7 +74,7 @@ entries: schema: olm.bundle name: package-with-webhooks.1.0.0 package: package-with-webhooks -image: docker-registry.operator-controller-e2e.svc.cluster.local:5000/bundles/registry-v1/prometheus-with-webhooks.v1.0.0 +image: docker-registry.operator-controller-e2e.svc.cluster.local:5000/bundles/registry-v1/prometheus-with-webhooks:v1.0.0 properties: - type: olm.package value: