controllers: take a newPluginManager func in constructors

Signed-off-by: Steve Kriss <steve@heptio.com>
This commit is contained in:
Steve Kriss
2018-08-25 12:53:56 -07:00
parent 6445dbf1c7
commit 729d733986
11 changed files with 40 additions and 78 deletions

View File

@@ -57,9 +57,8 @@ func NewBackupSyncController(
syncPeriod time.Duration,
namespace string,
defaultBackupLocation string,
pluginRegistry plugin.Registry,
newPluginManager func(logrus.FieldLogger) plugin.Manager,
logger logrus.FieldLogger,
logLevel logrus.Level,
) Interface {
if syncPeriod < time.Minute {
logger.Infof("Provided backup sync period %v is too short. Setting to 1 minute", syncPeriod)
@@ -74,9 +73,9 @@ func NewBackupSyncController(
backupLister: backupInformer.Lister(),
backupStorageLocationLister: backupStorageLocationInformer.Lister(),
newPluginManager: func(logger logrus.FieldLogger) plugin.Manager {
return plugin.NewManager(logger, logLevel, pluginRegistry)
},
// use variables to refer to these functions so they can be
// replaced with fakes for testing.
newPluginManager: newPluginManager,
listCloudBackups: cloudprovider.ListBackups,
}