From b59350c0c90f3f5f53deb02cb285642822cc64f3 Mon Sep 17 00:00:00 2001 From: Todd Short Date: Fri, 3 May 2024 09:56:47 -0400 Subject: [PATCH] Move helm-operator-plugin Signed-off-by: Todd Short --- go.mod | 2 +- go.sum | 4 +- .../clusterextension_controller.go | 2 +- .../predicate/depedent.go | 81 ------------------- 4 files changed, 4 insertions(+), 85 deletions(-) delete mode 100644 internal/rukpak/helm-operator-plugins/predicate/depedent.go diff --git a/go.mod b/go.mod index 7f79a518f..35f886efb 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/operator-framework/deppy v0.3.0 github.com/operator-framework/helm-operator-plugins v0.2.1 github.com/operator-framework/operator-registry v1.40.0 - github.com/operator-framework/rukpak v0.20.1-0.20240502203826-72cffe62499b + github.com/operator-framework/rukpak v0.20.1-0.20240503190249-f2fc69ef9ff1 github.com/spf13/pflag v1.0.5 github.com/stretchr/testify v1.9.0 github.com/vmware-tanzu/carvel-kapp-controller v0.51.0 diff --git a/go.sum b/go.sum index 080536140..6f085e80a 100644 --- a/go.sum +++ b/go.sum @@ -408,8 +408,8 @@ github.com/operator-framework/operator-lib v0.12.0 h1:OzpMU5N7mvFgg/uje8FUUeD24A github.com/operator-framework/operator-lib v0.12.0/go.mod h1:ClpLUI7hctEF7F5DBe/kg041dq/4NLR7XC5tArY7bG4= github.com/operator-framework/operator-registry v1.40.0 h1:CaYNE4F/jzahpC7UCILItaIHmB5/oE0sS066nK+5Glw= github.com/operator-framework/operator-registry v1.40.0/go.mod h1:D2YxapkfRDgjqNTO9d3h3v0DeREbV+8utCLG52zrOy4= -github.com/operator-framework/rukpak v0.20.1-0.20240502203826-72cffe62499b h1:WP/2bHrZ5e/O4cu52I593CqsAUrRA0t6febZuRn8Vmo= -github.com/operator-framework/rukpak v0.20.1-0.20240502203826-72cffe62499b/go.mod h1:WAyS3DXZ19pLg/324PEoudWZmaRlYZ6i4j4NV3/T/mI= +github.com/operator-framework/rukpak v0.20.1-0.20240503190249-f2fc69ef9ff1 h1:dB9owrQy5d/yjHuPNLw1dkudfWYLldJQBbmZ6pq+EAg= +github.com/operator-framework/rukpak v0.20.1-0.20240503190249-f2fc69ef9ff1/go.mod h1:WAyS3DXZ19pLg/324PEoudWZmaRlYZ6i4j4NV3/T/mI= github.com/otiai10/copy v1.14.0 h1:dCI/t1iTdYGtkvCuBG2BgR6KZa83PTclw4U5n2wAllU= github.com/otiai10/copy v1.14.0/go.mod h1:ECfuL02W+/FkTWZWgQqXPWZgW9oeKCSQ5qVfSc4qc4w= github.com/otiai10/mint v1.5.1 h1:XaPLeE+9vGbuyEHem1JNk3bYc7KKqyI/na0/mLd/Kks= diff --git a/internal/controllers/clusterextension_controller.go b/internal/controllers/clusterextension_controller.go index 3c180e2d1..aec751478 100644 --- a/internal/controllers/clusterextension_controller.go +++ b/internal/controllers/clusterextension_controller.go @@ -61,6 +61,7 @@ import ( helmclient "github.com/operator-framework/helm-operator-plugins/pkg/client" "github.com/operator-framework/operator-registry/alpha/declcfg" rukpakv1alpha2 "github.com/operator-framework/rukpak/api/v1alpha2" + helmpredicate "github.com/operator-framework/rukpak/pkg/helm-operator-plugins/predicate" rukpaksource "github.com/operator-framework/rukpak/pkg/source" "github.com/operator-framework/rukpak/pkg/storage" "github.com/operator-framework/rukpak/pkg/util" @@ -72,7 +73,6 @@ import ( "github.com/operator-framework/operator-controller/internal/handler" "github.com/operator-framework/operator-controller/internal/labels" "github.com/operator-framework/operator-controller/internal/packageerrors" - helmpredicate "github.com/operator-framework/operator-controller/internal/rukpak/helm-operator-plugins/predicate" ) // ClusterExtensionReconciler reconciles a ClusterExtension object diff --git a/internal/rukpak/helm-operator-plugins/predicate/depedent.go b/internal/rukpak/helm-operator-plugins/predicate/depedent.go deleted file mode 100644 index 46a3f89a5..000000000 --- a/internal/rukpak/helm-operator-plugins/predicate/depedent.go +++ /dev/null @@ -1,81 +0,0 @@ -/* -Copyright 2020 The Operator-SDK Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package predicate - -import ( - "reflect" - - "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" - "sigs.k8s.io/controller-runtime/pkg/event" - logf "sigs.k8s.io/controller-runtime/pkg/log" - crtpredicate "sigs.k8s.io/controller-runtime/pkg/predicate" -) - -var log = logf.Log.WithName("predicate") - -type GenerationChangedPredicate = crtpredicate.GenerationChangedPredicate - -// DependentPredicateFuncs returns functions defined for filtering events -func DependentPredicateFuncs() crtpredicate.Funcs { - dependentPredicate := crtpredicate.Funcs{ - // We don't need to reconcile dependent resource creation events - // because dependent resources are only ever created during - // reconciliation. Another reconcile would be redundant. - CreateFunc: func(e event.CreateEvent) bool { - o := e.Object.(*unstructured.Unstructured) - log.V(1).Info("Skipping reconciliation for dependent resource creation", "name", o.GetName(), "namespace", o.GetNamespace(), "apiVersion", o.GroupVersionKind().GroupVersion(), "kind", o.GroupVersionKind().Kind) - return false - }, - - // Reconcile when a dependent resource is deleted so that it can be - // recreated. - DeleteFunc: func(e event.DeleteEvent) bool { - o := e.Object.(*unstructured.Unstructured) - log.V(1).Info("Reconciling due to dependent resource deletion", "name", o.GetName(), "namespace", o.GetNamespace(), "apiVersion", o.GroupVersionKind().GroupVersion(), "kind", o.GroupVersionKind().Kind) - return true - }, - - // Don't reconcile when a generic event is received for a dependent - GenericFunc: func(e event.GenericEvent) bool { - o := e.Object.(*unstructured.Unstructured) - log.V(1).Info("Skipping reconcile due to generic event", "name", o.GetName(), "namespace", o.GetNamespace(), "apiVersion", o.GroupVersionKind().GroupVersion(), "kind", o.GroupVersionKind().Kind) - return false - }, - - // Reconcile when a dependent resource is updated, so that it can - // be patched back to the resource managed by the CR, if - // necessary. Ignore updates that only change the status and - // resourceVersion. - UpdateFunc: func(e event.UpdateEvent) bool { - oldObj := e.ObjectOld.(*unstructured.Unstructured).DeepCopy() - newObj := e.ObjectNew.(*unstructured.Unstructured).DeepCopy() - - delete(oldObj.Object, "status") - delete(newObj.Object, "status") - oldObj.SetResourceVersion("") - newObj.SetResourceVersion("") - - if reflect.DeepEqual(oldObj.Object, newObj.Object) { - return false - } - log.V(1).Info("Reconciling due to dependent resource update", "name", newObj.GetName(), "namespace", newObj.GetNamespace(), "apiVersion", newObj.GroupVersionKind().GroupVersion(), "kind", newObj.GroupVersionKind().Kind) - return true - }, - } - - return dependentPredicate -}