Skip to content

Commit

Permalink
scope patch to instance, remove EventRecorder
Browse files Browse the repository at this point in the history
Signed-off-by: Troy Connor <[email protected]>
  • Loading branch information
troy0820 committed Nov 29, 2023
1 parent 454d632 commit 9a3f61f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
16 changes: 8 additions & 8 deletions controllers/azuremanagedcontrolplane_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,10 @@ import (
// AzureManagedControlPlaneReconciler reconciles an AzureManagedControlPlane object.
type AzureManagedControlPlaneReconciler struct {
client.Client
Recorder record.EventRecorder
ReconcileTimeout time.Duration
WatchFilterValue string
Recorder record.EventRecorder
ReconcileTimeout time.Duration
WatchFilterValue string
getNewAzureManagedControlPlaneReconciler func(scope *scope.ManagedControlPlaneScope) (*azureManagedControlPlaneService, error)
}

// SetupWithManager initializes this controller with a manager.
Expand All @@ -61,6 +62,7 @@ func (amcpr *AzureManagedControlPlaneReconciler) SetupWithManager(ctx context.Co
)
defer done()

amcpr.getNewAzureManagedControlPlaneReconciler = newAzureManagedControlPlaneReconciler
var r reconcile.Reconciler = amcpr
if options.Cache != nil {
r = coalescing.NewReconciler(amcpr, options.Cache, log)
Expand Down Expand Up @@ -238,7 +240,7 @@ func (amcpr *AzureManagedControlPlaneReconciler) reconcileNormal(ctx context.Con
}
}

svc, err := getNewAzureManagedControlPlaneReconciler(scope)
svc, err := amcpr.getNewAzureManagedControlPlaneReconciler(scope)
if err != nil {
return reconcile.Result{}, errors.Wrap(err, "failed to create azureManagedControlPlane service")
}
Expand Down Expand Up @@ -279,7 +281,7 @@ func (amcpr *AzureManagedControlPlaneReconciler) reconcilePause(ctx context.Cont

log.Info("Reconciling AzureManagedControlPlane pause")

svc, err := getNewAzureManagedControlPlaneReconciler(scope)
svc, err := amcpr.getNewAzureManagedControlPlaneReconciler(scope)
if err != nil {
return reconcile.Result{}, errors.Wrap(err, "failed to create azureManagedControlPlane service")
}
Expand All @@ -296,7 +298,7 @@ func (amcpr *AzureManagedControlPlaneReconciler) reconcileDelete(ctx context.Con

log.Info("Reconciling AzureManagedControlPlane delete")

svc, err := getNewAzureManagedControlPlaneReconciler(scope)
svc, err := amcpr.getNewAzureManagedControlPlaneReconciler(scope)

Check warning on line 301 in controllers/azuremanagedcontrolplane_controller.go

View check run for this annotation

Codecov / codecov/patch

controllers/azuremanagedcontrolplane_controller.go#L301

Added line #L301 was not covered by tests
if err != nil {
return reconcile.Result{}, errors.Wrap(err, "failed to create azureManagedControlPlane service")
}
Expand Down Expand Up @@ -342,5 +344,3 @@ func (amcpr *AzureManagedControlPlaneReconciler) ClusterToAzureManagedControlPla

return nil
}

var getNewAzureManagedControlPlaneReconciler = newAzureManagedControlPlaneReconciler
14 changes: 7 additions & 7 deletions controllers/azuremanagedcontrolplane_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,11 @@ func TestAzureManagedControlPlaneReconcilePaused(t *testing.T) {
recorder := record.NewFakeRecorder(1)

reconciler := &AzureManagedControlPlaneReconciler{
Client: c,
Recorder: recorder,
ReconcileTimeout: reconciler.DefaultLoopTimeout,
WatchFilterValue: "",
Client: c,
Recorder: recorder,
ReconcileTimeout: reconciler.DefaultLoopTimeout,
WatchFilterValue: "",
getNewAzureManagedControlPlaneReconciler: newAzureManagedControlPlaneReconciler,
}
name := test.RandomName("paused", 10)
namespace := "default"
Expand Down Expand Up @@ -200,8 +201,7 @@ func TestAzureManagedControlPlaneReconcileNormal(t *testing.T) {

client := fake.NewClientBuilder().WithScheme(scheme).WithObjects(cp).WithStatusSubresource(cp).Build()
amcpr := &AzureManagedControlPlaneReconciler{
Client: client,
Recorder: record.NewFakeRecorder(42),
Client: client,
}

helper, err := patch.NewHelper(cp, client)
Expand All @@ -220,7 +220,7 @@ func TestAzureManagedControlPlaneReconcileNormal(t *testing.T) {
}
scopes.SetAdminKubeconfigData(createFakeKubeConfig())
scopes.SetUserKubeconfigData(createFakeKubeConfig())
getNewAzureManagedControlPlaneReconciler = func(scope *scope.ManagedControlPlaneScope) (*azureManagedControlPlaneService, error) {
amcpr.getNewAzureManagedControlPlaneReconciler = func(scope *scope.ManagedControlPlaneScope) (*azureManagedControlPlaneService, error) {
ctrlr := gomock.NewController(t)
defer ctrlr.Finish()
privateEndpointsClient := mock_privateendpoints.NewMockPrivateEndpointScope(ctrlr)
Expand Down

0 comments on commit 9a3f61f

Please sign in to comment.