Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making CRDAppFactory an interface #1498

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/controller/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
5 changes: 5 additions & 0 deletions pkg/app/app_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ import (
"k8s.io/client-go/kubernetes"
)

// ICRDAppFactory interface for CRDAppFactory
type ICRDAppFactory interface {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ICRDAppFactory Maybe not a good name let me know if you have some better suggestions.

NewCRDApp(*kcv1alpha1.App, logr.Logger) *CRDApp
}
Comment on lines +24 to +27
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// ICRDAppFactory interface for CRDAppFactory
type ICRDAppFactory interface {
NewCRDApp(*kcv1alpha1.App, logr.Logger) *CRDApp
}
// CRDAppCreator interface for CRDAppFactory
type CRDAppCreator interface {
Create(*kcv1alpha1.App, logr.Logger) *CRDApp
}


// CRDAppFactory allows to create CRDApps.
type CRDAppFactory struct {
CoreClient kubernetes.Interface
Expand Down
4 changes: 2 additions & 2 deletions pkg/app/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions pkg/app/reconciler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}{
Expand Down Expand Up @@ -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
Expand Down
Loading