Skip to content

Commit

Permalink
feat: create an interface for member controller (#875)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhiying-lin committed Jul 10, 2024
1 parent 5bdea80 commit 5215190
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ import (
"sigs.k8s.io/controller-runtime/pkg/predicate"

clusterv1beta1 "go.goms.io/fleet/apis/cluster/v1beta1"
"go.goms.io/fleet/pkg/controllers/work"
"go.goms.io/fleet/pkg/metrics"
"go.goms.io/fleet/pkg/propertyprovider"
"go.goms.io/fleet/pkg/utils/condition"
"go.goms.io/fleet/pkg/utils/controller"
)

// propertyProviderConfig is a group of settings for configuring the the property provider.
Expand Down Expand Up @@ -82,7 +82,7 @@ type Reconciler struct {
// the join/leave agent maintains the list of controllers in the member cluster
// so that it can make sure that all the agents on the member cluster have joined/left
// before updating the internal member cluster CR status
workController *work.ApplyWorkReconciler
workController controller.MemberController

// The context in which the reconciler runs in, i.e., the context that cancels
// when the member agent ends.
Expand Down Expand Up @@ -165,7 +165,7 @@ func NewReconciler(globalCtx context.Context,
hubClient client.Client,
memberCfg *rest.Config,
memberClient client.Client,
workController *work.ApplyWorkReconciler,
workController controller.MemberController,
propertyProvider propertyprovider.PropertyProvider,
) (*Reconciler, error) {
rawMemberClientSet, err := kubernetes.NewForConfig(memberCfg)
Expand Down
10 changes: 10 additions & 0 deletions pkg/utils/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,3 +345,13 @@ func FetchAllClusterResourceSnapshots(ctx context.Context, k8Client client.Clien
}
return resourceSnapshots, nil
}

// MemberController configures how to join or leave the fleet as a member.
type MemberController interface {
// Join describes the process of joining the fleet as a member.
Join(ctx context.Context) error

// Leaves describes the process of leaving the fleet as a member.
// For example, delete all the resources created by the member controller.
Leave(ctx context.Context) error
}

0 comments on commit 5215190

Please sign in to comment.