Skip to content

Commit

Permalink
switching back helm watch calls to use type casting to `client.Object…
Browse files Browse the repository at this point in the history
…` for consistency in the operator-sdk ecosystem

Signed-off-by: Adam D. Cornett <adc@redhat.com>
  • Loading branch information
acornett21 committed Nov 6, 2024
1 parent 4d9307d commit 56052cd
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions internal/helm/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ package controller

import (
"fmt"
"sigs.k8s.io/controller-runtime/pkg/client"
"strings"
"sync"
"time"
Expand All @@ -27,6 +26,7 @@ import (
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller"
crthandler "sigs.k8s.io/controller-runtime/pkg/handler"
logf "sigs.k8s.io/controller-runtime/pkg/log"
Expand Down Expand Up @@ -82,7 +82,7 @@ func Add(mgr manager.Manager, options WatchOptions) error {
o := &unstructured.Unstructured{}
o.SetGroupVersionKind(options.GVK)

if err := c.Watch(source.Kind(mgr.GetCache(), o, &libhandler.InstrumentedEnqueueRequestForObject[*unstructured.Unstructured]{})); err != nil {
if err := c.Watch(source.Kind(mgr.GetCache(), client.Object(o), &libhandler.InstrumentedEnqueueRequestForObject[client.Object]{})); err != nil {
return err
}

Expand Down Expand Up @@ -138,19 +138,19 @@ func watchDependentResources(mgr manager.Manager, r *HelmOperatorReconciler, c c

if useOwnerRef { // Setup watch using owner references.
err = c.Watch(
source.Kind[client.Object](
source.Kind(
mgr.GetCache(),
unstructuredObj,
client.Object(unstructuredObj),
crthandler.TypedEnqueueRequestForOwner[client.Object](mgr.GetScheme(), mgr.GetRESTMapper(), owner, crthandler.OnlyControllerOwner()),
predicate.DependentPredicate{}))
if err != nil {
return err
}
} else { // Setup watch using annotations.
err = c.Watch(
source.Kind[client.Object](
source.Kind(
mgr.GetCache(),
unstructuredObj,
client.Object(unstructuredObj),
&libhandler.EnqueueRequestForAnnotation[client.Object]{Type: gvkDependent.GroupKind()},
predicate.DependentPredicate{}))
if err != nil {
Expand Down

0 comments on commit 56052cd

Please sign in to comment.