Skip to content

Commit d46919f

Browse files
committed
Making CRDAppFactory an interface
Signed-off-by: Yash Sethiya <[email protected]>
1 parent 8d2a1c9 commit d46919f

File tree

4 files changed

+10
-5
lines changed

4 files changed

+10
-5
lines changed

cmd/controller/run.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ func Run(opts Options, runLog logr.Logger) error {
205205
CacheFolder: cacheFolderApps,
206206
}
207207
reconciler := app.NewReconciler(kcClient, runLog.WithName("app"),
208-
appFactory, refTracker, updateStatusTracker, compInfo)
208+
&appFactory, refTracker, updateStatusTracker, compInfo)
209209

210210
ctrl, err := controller.New("app", mgr, controller.Options{
211211
Reconciler: NewUniqueReconciler(&ErrReconciler{

pkg/app/app_factory.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ import (
2121
"k8s.io/client-go/kubernetes"
2222
)
2323

24+
// ICRDAppFactory interface for CRDAppFactory
25+
type ICRDAppFactory interface {
26+
NewCRDApp(*kcv1alpha1.App, logr.Logger) *CRDApp
27+
}
28+
2429
// CRDAppFactory allows to create CRDApps.
2530
type CRDAppFactory struct {
2631
CoreClient kubernetes.Interface

pkg/app/reconciler.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ import (
2727
type Reconciler struct {
2828
appClient kcclient.Interface
2929
log logr.Logger
30-
crdAppFactory CRDAppFactory
30+
crdAppFactory ICRDAppFactory
3131
appRefTracker *reftracker.AppRefTracker
3232
appUpdateStatus *reftracker.AppUpdateStatus
3333
componentInfo ComponentInfo
3434
}
3535

3636
// NewReconciler constructs new Reconciler.
37-
func NewReconciler(appClient kcclient.Interface, log logr.Logger, crdAppFactory CRDAppFactory,
37+
func NewReconciler(appClient kcclient.Interface, log logr.Logger, crdAppFactory ICRDAppFactory,
3838
appRefTracker *reftracker.AppRefTracker, appUpdateStatus *reftracker.AppUpdateStatus, componentInfo ComponentInfo) *Reconciler {
3939
return &Reconciler{appClient: appClient,
4040
log: log,

pkg/app/reconciler_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func Test_AppRefTracker_HasAppRemovedForSecrets_ThatAreNoLongerUsedByApp(t *test
3838
appKey := reftracker.NewAppKey(app.Name, app.Namespace)
3939
appRefTracker.ReconcileRefs(refKeyMap, appKey)
4040

41-
ar := apppkg.NewReconciler(nil, testr.New(t), apppkg.CRDAppFactory{}, appRefTracker, nil, FakeComponentInfo{})
41+
ar := apppkg.NewReconciler(nil, testr.New(t), &apppkg.CRDAppFactory{}, appRefTracker, nil, FakeComponentInfo{})
4242

4343
// This map represents the secrets the App has on its spec
4444
refMap := map[reftracker.RefKey]struct{}{
@@ -90,7 +90,7 @@ func Test_AppRefTracker_HasNoAppsRemoved_WhenRefsRemainSame(t *testing.T) {
9090
appKey := reftracker.NewAppKey(app.Name, app.Namespace)
9191
appRefTracker.ReconcileRefs(refKeyMap, appKey)
9292

93-
ar := apppkg.NewReconciler(nil, testr.New(t), apppkg.CRDAppFactory{}, appRefTracker, nil, FakeComponentInfo{})
93+
ar := apppkg.NewReconciler(nil, testr.New(t), &apppkg.CRDAppFactory{}, appRefTracker, nil, FakeComponentInfo{})
9494

9595
// This map represents the secrets the App has
9696
// on its spec

0 commit comments

Comments
 (0)