@@ -20,9 +20,10 @@ import (
20
20
"context"
21
21
"fmt"
22
22
23
+ "github.com/go-logr/logr"
24
+ operatorv1 "github.com/operator-framework/api/pkg/operators/v1"
23
25
catalogd "github.com/operator-framework/catalogd/pkg/apis/core/v1beta1"
24
26
"github.com/operator-framework/deppy/pkg/deppy/solver"
25
- "github.com/operator-framework/operator-controller/controllers/validators"
26
27
rukpakv1alpha1 "github.com/operator-framework/rukpak/api/v1alpha1"
27
28
"k8s.io/apimachinery/pkg/api/equality"
28
29
apimeta "k8s.io/apimachinery/pkg/api/meta"
@@ -33,14 +34,14 @@ import (
33
34
utilerrors "k8s.io/apimachinery/pkg/util/errors"
34
35
"k8s.io/utils/pointer"
35
36
ctrl "sigs.k8s.io/controller-runtime"
36
- "sigs.k8s.io/controller-runtime/pkg/builder"
37
37
"sigs.k8s.io/controller-runtime/pkg/client"
38
38
"sigs.k8s.io/controller-runtime/pkg/handler"
39
39
"sigs.k8s.io/controller-runtime/pkg/log"
40
+ "sigs.k8s.io/controller-runtime/pkg/reconcile"
40
41
"sigs.k8s.io/controller-runtime/pkg/source"
41
42
42
- "github.com/operator-framework/operator-controller/internal/controllers/validators"
43
43
operatorsv1alpha1 "github.com/operator-framework/operator-controller/api/v1alpha1"
44
+ "github.com/operator-framework/operator-controller/internal/controllers/validators"
44
45
"github.com/operator-framework/operator-controller/internal/resolution"
45
46
"github.com/operator-framework/operator-controller/internal/resolution/variable_sources/bundles_and_dependencies"
46
47
"github.com/operator-framework/operator-controller/internal/resolution/variable_sources/entity"
@@ -293,8 +294,7 @@ func (r *OperatorReconciler) SetupWithManager(mgr ctrl.Manager) error {
293
294
err := ctrl .NewControllerManagedBy (mgr ).
294
295
For (& operatorsv1alpha1.Operator {}).
295
296
Watches (source .NewKindWithCache (& catalogd.CatalogSource {}, mgr .GetCache ()),
296
- handler .EnqueueRequestsFromMapFunc (operatorRequestsForCatalog (context .TODO (), mgr .GetClient (), mgr .GetLogger ())),
297
- builder .WithPredicates (newCatalogReadyTransitionPredicate ())).
297
+ handler .EnqueueRequestsFromMapFunc (operatorRequestsForCatalog (context .TODO (), mgr .GetClient (), mgr .GetLogger ()))).
298
298
Owns (& rukpakv1alpha1.BundleDeployment {}).
299
299
Complete (r )
300
300
@@ -430,3 +430,26 @@ func setInstalledStatusConditionUnknown(conditions *[]metav1.Condition, message
430
430
ObservedGeneration : generation ,
431
431
})
432
432
}
433
+
434
+ // Generate reconcile requests for all operators affected by a catalog change
435
+ func operatorRequestsForCatalog (ctx context.Context , c client.Reader , logger logr.Logger ) handler.MapFunc {
436
+ return func (object client.Object ) []reconcile.Request {
437
+ // no way of associating an operator to a catalog so create reconcile requests for everything
438
+ operators := operatorv1.OperatorList {}
439
+ err := c .List (ctx , & operators )
440
+ if err != nil {
441
+ logger .Error (err , "unable to enqueue operators for catalog reconcile" )
442
+ return nil
443
+ }
444
+ var requests []reconcile.Request
445
+ for _ , op := range operators .Items {
446
+ requests = append (requests , reconcile.Request {
447
+ NamespacedName : types.NamespacedName {
448
+ Namespace : op .GetNamespace (),
449
+ Name : op .GetName (),
450
+ },
451
+ })
452
+ }
453
+ return requests
454
+ }
455
+ }
0 commit comments