Skip to content

Commit

Permalink
SQUASH: cluster.{AwareRunnable -> Aware}
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 Apr 24, 2024
1 parent 6db0f6f commit 5bafe05
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion pkg/builder/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ func (blder *Builder) Build(r reconcile.Reconciler) (controller.Controller, erro

ctrl := blder.ctrl
if *blder.ctrlOptions.EngageWithProviderClusters {
// wrap as cluster.AwareRunnable to be engaged with provider clusters on demand
// wrap as cluster.Aware to be engaged with provider clusters on demand
ctrl = controller.NewMultiClusterController(ctrl, &blder.clusterWatcher)
}
if err := blder.mgr.Add(ctrl); err != nil {
Expand Down
10 changes: 5 additions & 5 deletions pkg/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ import (
intrec "sigs.k8s.io/controller-runtime/pkg/internal/recorder"
)

// AwareRunnable is an interface that can be implemented by runnable types
// that are cluster-aware.
type AwareRunnable interface {
// Engage gets called when the runnable should start operations for the given Cluster.
// Aware is an interface that can be implemented by components that
// can engage and disengange when clusters are added or removed.
type Aware interface {
// Engage gets called when the component should start operations for the given Cluster.
// The given context is tied to the Cluster's lifecycle and will be cancelled when the
// Cluster is removed or an error occurs.
//
Expand All @@ -53,7 +53,7 @@ type AwareRunnable interface {
// `--------'
Engage(context.Context, Cluster) error

// Disengage gets called when the runnable should stop operations for the given Cluster.
// Disengage gets called when the component should stop operations for the given Cluster.
Disengage(context.Context, Cluster) error
}

Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/multicluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
// running in. It engage and disengage clusters dynamically, starting the
// watches and stopping them.
type MultiClusterController interface {
cluster.AwareRunnable
cluster.Aware
Controller
}

Expand Down Expand Up @@ -65,7 +65,7 @@ func (c *multiClusterController) Engage(clusterCtx context.Context, cl cluster.C
}

// pass through in case the controller itself is cluster aware
if ctrl, ok := c.Controller.(cluster.AwareRunnable); ok {
if ctrl, ok := c.Controller.(cluster.Aware); ok {
if err := ctrl.Engage(clusterCtx, cl); err != nil {
return err
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/manager/internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ type controllerManager struct {

clusterLock sync.RWMutex // protects clusters
clusters map[string]*engagedCluster
clusterAwareRunnables []cluster.AwareRunnable
clusterAwareRunnables []cluster.Aware

// recorderProvider is used to generate event recorders that will be injected into Controllers
// (and EventHandlers, Sources and Predicates).
Expand Down Expand Up @@ -193,7 +193,7 @@ func (cm *controllerManager) Add(r Runnable) error {
}

func (cm *controllerManager) add(r Runnable) error {
if aware, ok := r.(cluster.AwareRunnable); ok {
if aware, ok := r.(cluster.Aware); ok {
cm.clusterAwareRunnables = append(cm.clusterAwareRunnables, aware)
}
return cm.runnables.Add(r)
Expand Down

0 comments on commit 5bafe05

Please sign in to comment.