Skip to content

Commit

Permalink
Make linter happy
Browse files Browse the repository at this point in the history
Signed-off-by: Dr. Stefan Schimanski <stefan.schimanski@gmail.com>
  • Loading branch information
sttts committed Mar 25, 2024
1 parent 05607e7 commit 684dc8e
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 15 deletions.
6 changes: 1 addition & 5 deletions pkg/builder/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,11 +253,7 @@ func (blder *Builder) do(r reconcile.Reconciler) error {
}

// Set the Watch
if err := blder.doWatch(); err != nil {
return err
}

return nil
return blder.doWatch()
}

func (blder *Builder) project(obj client.Object, proj objectProjection) (client.Object, error) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/builder/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ var _ = Describe("application", func() {
Name: dep.Name,
Kind: "Deployment",
APIVersion: "apps/v1",
Controller: pointer.Bool(true),
Controller: ptr.To(true),
UID: dep.UID,
},
},
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"github.com/go-logr/logr"
"k8s.io/client-go/util/workqueue"
"k8s.io/klog/v2"
"k8s.io/utils/pointer"
"k8s.io/utils/ptr"

"sigs.k8s.io/controller-runtime/pkg/handler"
"sigs.k8s.io/controller-runtime/pkg/internal/controller"
Expand Down Expand Up @@ -164,7 +164,7 @@ func NewUnmanaged(name string, mgr manager.Manager, options Options) (Controller
if options.WatchProviderClusters == nil {
options.WatchProviderClusters = mgr.GetControllerOptions().WatchProviderClusters
if options.WatchProviderClusters == nil { // should never happen
options.WatchProviderClusters = pointer.Bool(false)
options.WatchProviderClusters = ptr.To(false)
}
}

Expand Down
6 changes: 3 additions & 3 deletions pkg/handler/enqueue_owner.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,14 +208,14 @@ func (e *enqueueRequestForOwner) getOwnersReferences(object metav1.Object) []met
}

func (e *enqueueRequestForOwner) DeepCopyFor(c cluster.Cluster) DeepCopyableEventHandler {
copy := &enqueueRequestForOwner{
cpy := &enqueueRequestForOwner{
cluster: c,
ownerType: e.ownerType,
isController: e.isController,
mapper: c.GetRESTMapper(),
}
if err := copy.parseOwnerTypeGroupKind(c.GetScheme()); err != nil {
if err := cpy.parseOwnerTypeGroupKind(c.GetScheme()); err != nil {
panic(err)
}
return copy
return cpy
}
3 changes: 0 additions & 3 deletions pkg/internal/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,6 @@ func (c *Controller) Disengage(ctx context.Context, cluster cluster.Cluster) err

func (c *Controller) startClusterAwareWatchLocked(cldesc *clusterDescription, watchDesc *deepcopyableWatchDescription) error {
watch := &deepcopyableWatchDescription{src: watchDesc.src.DeepCopyFor(cldesc.Cluster), handler: watchDesc.handler.DeepCopyFor(cldesc.Cluster), predicates: watchDesc.predicates}
if watch == nil {
return nil
}
c.LogConstructor(nil).Info("Starting Cluster-Aware EventSource", "cluster", cldesc.Name(), "source", watch.src)
if err := watch.src.Start(cldesc.ctx, watch.handler, c.Queue, watch.predicates...); err != nil {
return err
Expand Down
12 changes: 12 additions & 0 deletions pkg/internal/source/kind.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,27 @@ import (
"sigs.k8s.io/controller-runtime/pkg/predicate"
)

// Source is a source of events (eh.g. Create, Update, Delete operations on Kubernetes Objects, Webhook callbacks, etc)
// which should be processed by event.EventHandlers to enqueue reconcile.Requests.
//
// * Use Kind for events originating in the cluster (e.g. Pod Create, Pod Update, Deployment Update).
//
// * Use Channel for events originating outside the cluster (eh.g. GitHub Webhook callback, Polling external urls).
//
// Users may build their own Source implementations.
type Source interface {
Start(context.Context, handler.EventHandler, workqueue.RateLimitingInterface, ...predicate.Predicate) error
}

// SyncingSource is a source that needs syncing prior to being usable. The controller
// will call its WaitForSync prior to starting workers.
type SyncingSource interface {
Source
WaitForSync(ctx context.Context) error
}

// DeepCopyableSyncingSource is a source that can be deep copied for a specific cluster.
// It is used in setups with a cluster provider set in the manager.
type DeepCopyableSyncingSource interface {
SyncingSource
DeepCopyFor(cluster cluster.Cluster) DeepCopyableSyncingSource
Expand Down
2 changes: 1 addition & 1 deletion pkg/reconcile/reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (r Request) String() string {
if r.ClusterName == "" {
return r.NamespacedName.String()
}
return "cluster://" + string(r.ClusterName) + string(types.Separator) + r.NamespacedName.String()
return "cluster://" + r.ClusterName + string(types.Separator) + r.NamespacedName.String()
}

/*
Expand Down

0 comments on commit 684dc8e

Please sign in to comment.