diff --git a/cmd/controller/run.go b/cmd/controller/run.go index 223c36f8b..d7dba6273 100644 --- a/cmd/controller/run.go +++ b/cmd/controller/run.go @@ -205,7 +205,7 @@ func Run(opts Options, runLog logr.Logger) error { CacheFolder: cacheFolderApps, } reconciler := app.NewReconciler(kcClient, runLog.WithName("app"), - appFactory, refTracker, updateStatusTracker, compInfo) + &appFactory, refTracker, updateStatusTracker, compInfo) ctrl, err := controller.New("app", mgr, controller.Options{ Reconciler: NewUniqueReconciler(&ErrReconciler{ diff --git a/pkg/app/app_factory.go b/pkg/app/app_factory.go index 79c290a27..d8d5ce029 100644 --- a/pkg/app/app_factory.go +++ b/pkg/app/app_factory.go @@ -21,6 +21,11 @@ import ( "k8s.io/client-go/kubernetes" ) +// ICRDAppFactory interface for CRDAppFactory +type ICRDAppFactory interface { + NewCRDApp(*kcv1alpha1.App, logr.Logger) *CRDApp +} + // CRDAppFactory allows to create CRDApps. type CRDAppFactory struct { CoreClient kubernetes.Interface diff --git a/pkg/app/reconciler.go b/pkg/app/reconciler.go index a51f4a2d0..8066274f6 100644 --- a/pkg/app/reconciler.go +++ b/pkg/app/reconciler.go @@ -27,14 +27,14 @@ import ( type Reconciler struct { appClient kcclient.Interface log logr.Logger - crdAppFactory CRDAppFactory + crdAppFactory ICRDAppFactory appRefTracker *reftracker.AppRefTracker appUpdateStatus *reftracker.AppUpdateStatus componentInfo ComponentInfo } // NewReconciler constructs new Reconciler. -func NewReconciler(appClient kcclient.Interface, log logr.Logger, crdAppFactory CRDAppFactory, +func NewReconciler(appClient kcclient.Interface, log logr.Logger, crdAppFactory ICRDAppFactory, appRefTracker *reftracker.AppRefTracker, appUpdateStatus *reftracker.AppUpdateStatus, componentInfo ComponentInfo) *Reconciler { return &Reconciler{appClient: appClient, log: log, diff --git a/pkg/app/reconciler_test.go b/pkg/app/reconciler_test.go index f2dcaca79..a92e116b1 100644 --- a/pkg/app/reconciler_test.go +++ b/pkg/app/reconciler_test.go @@ -38,7 +38,7 @@ func Test_AppRefTracker_HasAppRemovedForSecrets_ThatAreNoLongerUsedByApp(t *test appKey := reftracker.NewAppKey(app.Name, app.Namespace) appRefTracker.ReconcileRefs(refKeyMap, appKey) - ar := apppkg.NewReconciler(nil, testr.New(t), apppkg.CRDAppFactory{}, appRefTracker, nil, FakeComponentInfo{}) + ar := apppkg.NewReconciler(nil, testr.New(t), &apppkg.CRDAppFactory{}, appRefTracker, nil, FakeComponentInfo{}) // This map represents the secrets the App has on its spec refMap := map[reftracker.RefKey]struct{}{ @@ -90,7 +90,7 @@ func Test_AppRefTracker_HasNoAppsRemoved_WhenRefsRemainSame(t *testing.T) { appKey := reftracker.NewAppKey(app.Name, app.Namespace) appRefTracker.ReconcileRefs(refKeyMap, appKey) - ar := apppkg.NewReconciler(nil, testr.New(t), apppkg.CRDAppFactory{}, appRefTracker, nil, FakeComponentInfo{}) + ar := apppkg.NewReconciler(nil, testr.New(t), &apppkg.CRDAppFactory{}, appRefTracker, nil, FakeComponentInfo{}) // This map represents the secrets the App has // on its spec