Split velero plugin client into its own package

Signed-off-by: Carlisia <carlisiac@vmware.com>
This commit is contained in:
Carlisia
2019-03-15 11:32:11 -07:00
parent 1eac10ca9f
commit a71e43b2b7
32 changed files with 75 additions and 65 deletions

View File

@@ -61,7 +61,7 @@ import (
informers "github.com/heptio/velero/pkg/generated/informers/externalversions" informers "github.com/heptio/velero/pkg/generated/informers/externalversions"
"github.com/heptio/velero/pkg/metrics" "github.com/heptio/velero/pkg/metrics"
"github.com/heptio/velero/pkg/persistence" "github.com/heptio/velero/pkg/persistence"
"github.com/heptio/velero/pkg/plugin" "github.com/heptio/velero/pkg/plugin/clientmgmt"
"github.com/heptio/velero/pkg/podexec" "github.com/heptio/velero/pkg/podexec"
"github.com/heptio/velero/pkg/restic" "github.com/heptio/velero/pkg/restic"
"github.com/heptio/velero/pkg/restore" "github.com/heptio/velero/pkg/restore"
@@ -203,8 +203,8 @@ type server struct {
cancelFunc context.CancelFunc cancelFunc context.CancelFunc
logger logrus.FieldLogger logger logrus.FieldLogger
logLevel logrus.Level logLevel logrus.Level
pluginRegistry plugin.Registry pluginRegistry clientmgmt.Registry
pluginManager plugin.Manager pluginManager clientmgmt.Manager
resticManager restic.RepositoryManager resticManager restic.RepositoryManager
metrics *metrics.ServerMetrics metrics *metrics.ServerMetrics
config serverConfig config serverConfig
@@ -235,11 +235,11 @@ func newServer(namespace, baseName string, config serverConfig, logger *logrus.L
return nil, errors.WithStack(err) return nil, errors.WithStack(err)
} }
pluginRegistry := plugin.NewRegistry(config.pluginDir, logger, logger.Level) pluginRegistry := clientmgmt.NewRegistry(config.pluginDir, logger, logger.Level)
if err := pluginRegistry.DiscoverPlugins(); err != nil { if err := pluginRegistry.DiscoverPlugins(); err != nil {
return nil, err return nil, err
} }
pluginManager := plugin.NewManager(logger, logger.Level, pluginRegistry) pluginManager := clientmgmt.NewManager(logger, logger.Level, pluginRegistry)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@@ -520,8 +520,8 @@ func (s *server) runControllers(defaultVolumeSnapshotLocations map[string]string
// Initialize manual backup metrics // Initialize manual backup metrics
s.metrics.InitSchedule("") s.metrics.InitSchedule("")
newPluginManager := func(logger logrus.FieldLogger) plugin.Manager { newPluginManager := func(logger logrus.FieldLogger) clientmgmt.Manager {
return plugin.NewManager(logger, s.logLevel, s.pluginRegistry) return clientmgmt.NewManager(logger, s.logLevel, s.pluginRegistry)
} }
backupSyncController := controller.NewBackupSyncController( backupSyncController := controller.NewBackupSyncController(

View File

@@ -44,7 +44,7 @@ import (
listers "github.com/heptio/velero/pkg/generated/listers/velero/v1" listers "github.com/heptio/velero/pkg/generated/listers/velero/v1"
"github.com/heptio/velero/pkg/metrics" "github.com/heptio/velero/pkg/metrics"
"github.com/heptio/velero/pkg/persistence" "github.com/heptio/velero/pkg/persistence"
"github.com/heptio/velero/pkg/plugin" "github.com/heptio/velero/pkg/plugin/clientmgmt"
"github.com/heptio/velero/pkg/util/collections" "github.com/heptio/velero/pkg/util/collections"
"github.com/heptio/velero/pkg/util/encode" "github.com/heptio/velero/pkg/util/encode"
kubeutil "github.com/heptio/velero/pkg/util/kube" kubeutil "github.com/heptio/velero/pkg/util/kube"
@@ -60,7 +60,7 @@ type backupController struct {
client velerov1client.BackupsGetter client velerov1client.BackupsGetter
clock clock.Clock clock clock.Clock
backupLogLevel logrus.Level backupLogLevel logrus.Level
newPluginManager func(logrus.FieldLogger) plugin.Manager newPluginManager func(logrus.FieldLogger) clientmgmt.Manager
backupTracker BackupTracker backupTracker BackupTracker
backupLocationLister listers.BackupStorageLocationLister backupLocationLister listers.BackupStorageLocationLister
defaultBackupLocation string defaultBackupLocation string
@@ -76,7 +76,7 @@ func NewBackupController(
backupper pkgbackup.Backupper, backupper pkgbackup.Backupper,
logger logrus.FieldLogger, logger logrus.FieldLogger,
backupLogLevel logrus.Level, backupLogLevel logrus.Level,
newPluginManager func(logrus.FieldLogger) plugin.Manager, newPluginManager func(logrus.FieldLogger) clientmgmt.Manager,
backupTracker BackupTracker, backupTracker BackupTracker,
backupLocationInformer informers.BackupStorageLocationInformer, backupLocationInformer informers.BackupStorageLocationInformer,
defaultBackupLocation string, defaultBackupLocation string,

View File

@@ -40,7 +40,7 @@ import (
"github.com/heptio/velero/pkg/metrics" "github.com/heptio/velero/pkg/metrics"
"github.com/heptio/velero/pkg/persistence" "github.com/heptio/velero/pkg/persistence"
persistencemocks "github.com/heptio/velero/pkg/persistence/mocks" persistencemocks "github.com/heptio/velero/pkg/persistence/mocks"
"github.com/heptio/velero/pkg/plugin" "github.com/heptio/velero/pkg/plugin/clientmgmt"
pluginmocks "github.com/heptio/velero/pkg/plugin/mocks" pluginmocks "github.com/heptio/velero/pkg/plugin/mocks"
"github.com/heptio/velero/pkg/plugin/velero" "github.com/heptio/velero/pkg/plugin/velero"
"github.com/heptio/velero/pkg/util/logging" "github.com/heptio/velero/pkg/util/logging"
@@ -305,7 +305,7 @@ func TestProcessBackupCompletions(t *testing.T) {
backupTracker: NewBackupTracker(), backupTracker: NewBackupTracker(),
metrics: metrics.NewServerMetrics(), metrics: metrics.NewServerMetrics(),
clock: clock.NewFakeClock(now), clock: clock.NewFakeClock(now),
newPluginManager: func(logrus.FieldLogger) plugin.Manager { return pluginManager }, newPluginManager: func(logrus.FieldLogger) clientmgmt.Manager { return pluginManager },
newBackupStore: func(*v1.BackupStorageLocation, persistence.ObjectStoreGetter, logrus.FieldLogger) (persistence.BackupStore, error) { newBackupStore: func(*v1.BackupStorageLocation, persistence.ObjectStoreGetter, logrus.FieldLogger) (persistence.BackupStore, error) {
return backupStore, nil return backupStore, nil
}, },

View File

@@ -38,7 +38,7 @@ import (
informers "github.com/heptio/velero/pkg/generated/informers/externalversions/velero/v1" informers "github.com/heptio/velero/pkg/generated/informers/externalversions/velero/v1"
listers "github.com/heptio/velero/pkg/generated/listers/velero/v1" listers "github.com/heptio/velero/pkg/generated/listers/velero/v1"
"github.com/heptio/velero/pkg/persistence" "github.com/heptio/velero/pkg/persistence"
"github.com/heptio/velero/pkg/plugin" "github.com/heptio/velero/pkg/plugin/clientmgmt"
"github.com/heptio/velero/pkg/plugin/velero" "github.com/heptio/velero/pkg/plugin/velero"
"github.com/heptio/velero/pkg/restic" "github.com/heptio/velero/pkg/restic"
"github.com/heptio/velero/pkg/util/kube" "github.com/heptio/velero/pkg/util/kube"
@@ -61,7 +61,7 @@ type backupDeletionController struct {
snapshotLocationLister listers.VolumeSnapshotLocationLister snapshotLocationLister listers.VolumeSnapshotLocationLister
processRequestFunc func(*v1.DeleteBackupRequest) error processRequestFunc func(*v1.DeleteBackupRequest) error
clock clock.Clock clock clock.Clock
newPluginManager func(logrus.FieldLogger) plugin.Manager newPluginManager func(logrus.FieldLogger) clientmgmt.Manager
newBackupStore func(*v1.BackupStorageLocation, persistence.ObjectStoreGetter, logrus.FieldLogger) (persistence.BackupStore, error) newBackupStore func(*v1.BackupStorageLocation, persistence.ObjectStoreGetter, logrus.FieldLogger) (persistence.BackupStore, error)
} }
@@ -78,7 +78,7 @@ func NewBackupDeletionController(
podvolumeBackupInformer informers.PodVolumeBackupInformer, podvolumeBackupInformer informers.PodVolumeBackupInformer,
backupLocationInformer informers.BackupStorageLocationInformer, backupLocationInformer informers.BackupStorageLocationInformer,
snapshotLocationInformer informers.VolumeSnapshotLocationInformer, snapshotLocationInformer informers.VolumeSnapshotLocationInformer,
newPluginManager func(logrus.FieldLogger) plugin.Manager, newPluginManager func(logrus.FieldLogger) clientmgmt.Manager,
) Interface { ) Interface {
c := &backupDeletionController{ c := &backupDeletionController{
genericController: newGenericController("backup-deletion", logger), genericController: newGenericController("backup-deletion", logger),
@@ -364,7 +364,7 @@ func (c *backupDeletionController) processRequest(req *v1.DeleteBackupRequest) e
func blockStoreForSnapshotLocation( func blockStoreForSnapshotLocation(
namespace, snapshotLocationName string, namespace, snapshotLocationName string,
snapshotLocationLister listers.VolumeSnapshotLocationLister, snapshotLocationLister listers.VolumeSnapshotLocationLister,
pluginManager plugin.Manager, pluginManager clientmgmt.Manager,
) (velero.BlockStore, error) { ) (velero.BlockStore, error) {
snapshotLocation, err := snapshotLocationLister.VolumeSnapshotLocations(namespace).Get(snapshotLocationName) snapshotLocation, err := snapshotLocationLister.VolumeSnapshotLocations(namespace).Get(snapshotLocationName)
if err != nil { if err != nil {
@@ -383,7 +383,7 @@ func blockStoreForSnapshotLocation(
return blockStore, nil return blockStore, nil
} }
func (c *backupDeletionController) backupStoreForBackup(backup *v1.Backup, pluginManager plugin.Manager, log logrus.FieldLogger) (persistence.BackupStore, error) { func (c *backupDeletionController) backupStoreForBackup(backup *v1.Backup, pluginManager clientmgmt.Manager, log logrus.FieldLogger) (persistence.BackupStore, error) {
backupLocation, err := c.backupLocationLister.BackupStorageLocations(backup.Namespace).Get(backup.Spec.StorageLocation) backupLocation, err := c.backupLocationLister.BackupStorageLocations(backup.Namespace).Get(backup.Spec.StorageLocation)
if err != nil { if err != nil {
return nil, errors.WithStack(err) return nil, errors.WithStack(err)

View File

@@ -38,7 +38,7 @@ import (
informers "github.com/heptio/velero/pkg/generated/informers/externalversions" informers "github.com/heptio/velero/pkg/generated/informers/externalversions"
"github.com/heptio/velero/pkg/persistence" "github.com/heptio/velero/pkg/persistence"
persistencemocks "github.com/heptio/velero/pkg/persistence/mocks" persistencemocks "github.com/heptio/velero/pkg/persistence/mocks"
"github.com/heptio/velero/pkg/plugin" "github.com/heptio/velero/pkg/plugin/clientmgmt"
pluginmocks "github.com/heptio/velero/pkg/plugin/mocks" pluginmocks "github.com/heptio/velero/pkg/plugin/mocks"
velerotest "github.com/heptio/velero/pkg/util/test" velerotest "github.com/heptio/velero/pkg/util/test"
"github.com/heptio/velero/pkg/volume" "github.com/heptio/velero/pkg/volume"
@@ -146,7 +146,7 @@ func setupBackupDeletionControllerTest(objects ...runtime.Object) *backupDeletio
sharedInformers.Velero().V1().PodVolumeBackups(), sharedInformers.Velero().V1().PodVolumeBackups(),
sharedInformers.Velero().V1().BackupStorageLocations(), sharedInformers.Velero().V1().BackupStorageLocations(),
sharedInformers.Velero().V1().VolumeSnapshotLocations(), sharedInformers.Velero().V1().VolumeSnapshotLocations(),
func(logrus.FieldLogger) plugin.Manager { return pluginManager }, func(logrus.FieldLogger) clientmgmt.Manager { return pluginManager },
).(*backupDeletionController), ).(*backupDeletionController),
req: req, req: req,
@@ -389,7 +389,7 @@ func TestBackupDeletionControllerProcessRequest(t *testing.T) {
pluginManager := &pluginmocks.Manager{} pluginManager := &pluginmocks.Manager{}
pluginManager.On("GetBlockStore", "provider-1").Return(td.blockStore, nil) pluginManager.On("GetBlockStore", "provider-1").Return(td.blockStore, nil)
pluginManager.On("CleanupClients") pluginManager.On("CleanupClients")
td.controller.newPluginManager = func(logrus.FieldLogger) plugin.Manager { return pluginManager } td.controller.newPluginManager = func(logrus.FieldLogger) clientmgmt.Manager { return pluginManager }
td.backupStore.On("DeleteBackup", td.req.Spec.BackupName).Return(nil) td.backupStore.On("DeleteBackup", td.req.Spec.BackupName).Return(nil)
td.backupStore.On("DeleteRestore", "restore-1").Return(nil) td.backupStore.On("DeleteRestore", "restore-1").Return(nil)
@@ -528,7 +528,7 @@ func TestBackupDeletionControllerProcessRequest(t *testing.T) {
pluginManager := &pluginmocks.Manager{} pluginManager := &pluginmocks.Manager{}
pluginManager.On("GetBlockStore", "provider-1").Return(td.blockStore, nil) pluginManager.On("GetBlockStore", "provider-1").Return(td.blockStore, nil)
pluginManager.On("CleanupClients") pluginManager.On("CleanupClients")
td.controller.newPluginManager = func(logrus.FieldLogger) plugin.Manager { return pluginManager } td.controller.newPluginManager = func(logrus.FieldLogger) clientmgmt.Manager { return pluginManager }
td.backupStore.On("GetBackupVolumeSnapshots", td.req.Spec.BackupName).Return(snapshots, nil) td.backupStore.On("GetBackupVolumeSnapshots", td.req.Spec.BackupName).Return(snapshots, nil)
td.backupStore.On("DeleteBackup", td.req.Spec.BackupName).Return(nil) td.backupStore.On("DeleteBackup", td.req.Spec.BackupName).Return(nil)

View File

@@ -34,7 +34,7 @@ import (
informers "github.com/heptio/velero/pkg/generated/informers/externalversions/velero/v1" informers "github.com/heptio/velero/pkg/generated/informers/externalversions/velero/v1"
listers "github.com/heptio/velero/pkg/generated/listers/velero/v1" listers "github.com/heptio/velero/pkg/generated/listers/velero/v1"
"github.com/heptio/velero/pkg/persistence" "github.com/heptio/velero/pkg/persistence"
"github.com/heptio/velero/pkg/plugin" "github.com/heptio/velero/pkg/plugin/clientmgmt"
"github.com/heptio/velero/pkg/util/stringslice" "github.com/heptio/velero/pkg/util/stringslice"
) )
@@ -47,7 +47,7 @@ type backupSyncController struct {
backupStorageLocationLister listers.BackupStorageLocationLister backupStorageLocationLister listers.BackupStorageLocationLister
namespace string namespace string
defaultBackupLocation string defaultBackupLocation string
newPluginManager func(logrus.FieldLogger) plugin.Manager newPluginManager func(logrus.FieldLogger) clientmgmt.Manager
newBackupStore func(*velerov1api.BackupStorageLocation, persistence.ObjectStoreGetter, logrus.FieldLogger) (persistence.BackupStore, error) newBackupStore func(*velerov1api.BackupStorageLocation, persistence.ObjectStoreGetter, logrus.FieldLogger) (persistence.BackupStore, error)
} }
@@ -59,7 +59,7 @@ func NewBackupSyncController(
syncPeriod time.Duration, syncPeriod time.Duration,
namespace string, namespace string,
defaultBackupLocation string, defaultBackupLocation string,
newPluginManager func(logrus.FieldLogger) plugin.Manager, newPluginManager func(logrus.FieldLogger) clientmgmt.Manager,
logger logrus.FieldLogger, logger logrus.FieldLogger,
) Interface { ) Interface {
if syncPeriod < time.Minute { if syncPeriod < time.Minute {

View File

@@ -35,7 +35,7 @@ import (
informers "github.com/heptio/velero/pkg/generated/informers/externalversions" informers "github.com/heptio/velero/pkg/generated/informers/externalversions"
"github.com/heptio/velero/pkg/persistence" "github.com/heptio/velero/pkg/persistence"
persistencemocks "github.com/heptio/velero/pkg/persistence/mocks" persistencemocks "github.com/heptio/velero/pkg/persistence/mocks"
"github.com/heptio/velero/pkg/plugin" "github.com/heptio/velero/pkg/plugin/clientmgmt"
pluginmocks "github.com/heptio/velero/pkg/plugin/mocks" pluginmocks "github.com/heptio/velero/pkg/plugin/mocks"
"github.com/heptio/velero/pkg/util/stringslice" "github.com/heptio/velero/pkg/util/stringslice"
velerotest "github.com/heptio/velero/pkg/util/test" velerotest "github.com/heptio/velero/pkg/util/test"
@@ -193,7 +193,7 @@ func TestBackupSyncControllerRun(t *testing.T) {
time.Duration(0), time.Duration(0),
test.namespace, test.namespace,
"", "",
func(logrus.FieldLogger) plugin.Manager { return pluginManager }, func(logrus.FieldLogger) clientmgmt.Manager { return pluginManager },
velerotest.NewLogger(), velerotest.NewLogger(),
).(*backupSyncController) ).(*backupSyncController)

View File

@@ -35,7 +35,7 @@ import (
informers "github.com/heptio/velero/pkg/generated/informers/externalversions/velero/v1" informers "github.com/heptio/velero/pkg/generated/informers/externalversions/velero/v1"
listers "github.com/heptio/velero/pkg/generated/listers/velero/v1" listers "github.com/heptio/velero/pkg/generated/listers/velero/v1"
"github.com/heptio/velero/pkg/persistence" "github.com/heptio/velero/pkg/persistence"
"github.com/heptio/velero/pkg/plugin" "github.com/heptio/velero/pkg/plugin/clientmgmt"
"github.com/heptio/velero/pkg/util/kube" "github.com/heptio/velero/pkg/util/kube"
) )
@@ -48,7 +48,7 @@ type downloadRequestController struct {
clock clock.Clock clock clock.Clock
backupLocationLister listers.BackupStorageLocationLister backupLocationLister listers.BackupStorageLocationLister
backupLister listers.BackupLister backupLister listers.BackupLister
newPluginManager func(logrus.FieldLogger) plugin.Manager newPluginManager func(logrus.FieldLogger) clientmgmt.Manager
newBackupStore func(*v1.BackupStorageLocation, persistence.ObjectStoreGetter, logrus.FieldLogger) (persistence.BackupStore, error) newBackupStore func(*v1.BackupStorageLocation, persistence.ObjectStoreGetter, logrus.FieldLogger) (persistence.BackupStore, error)
} }
@@ -59,7 +59,7 @@ func NewDownloadRequestController(
restoreInformer informers.RestoreInformer, restoreInformer informers.RestoreInformer,
backupLocationInformer informers.BackupStorageLocationInformer, backupLocationInformer informers.BackupStorageLocationInformer,
backupInformer informers.BackupInformer, backupInformer informers.BackupInformer,
newPluginManager func(logrus.FieldLogger) plugin.Manager, newPluginManager func(logrus.FieldLogger) clientmgmt.Manager,
logger logrus.FieldLogger, logger logrus.FieldLogger,
) Interface { ) Interface {
c := &downloadRequestController{ c := &downloadRequestController{

View File

@@ -32,7 +32,7 @@ import (
informers "github.com/heptio/velero/pkg/generated/informers/externalversions" informers "github.com/heptio/velero/pkg/generated/informers/externalversions"
"github.com/heptio/velero/pkg/persistence" "github.com/heptio/velero/pkg/persistence"
persistencemocks "github.com/heptio/velero/pkg/persistence/mocks" persistencemocks "github.com/heptio/velero/pkg/persistence/mocks"
"github.com/heptio/velero/pkg/plugin" "github.com/heptio/velero/pkg/plugin/clientmgmt"
pluginmocks "github.com/heptio/velero/pkg/plugin/mocks" pluginmocks "github.com/heptio/velero/pkg/plugin/mocks"
kubeutil "github.com/heptio/velero/pkg/util/kube" kubeutil "github.com/heptio/velero/pkg/util/kube"
velerotest "github.com/heptio/velero/pkg/util/test" velerotest "github.com/heptio/velero/pkg/util/test"
@@ -59,7 +59,7 @@ func newDownloadRequestTestHarness(t *testing.T) *downloadRequestTestHarness {
informerFactory.Velero().V1().Restores(), informerFactory.Velero().V1().Restores(),
informerFactory.Velero().V1().BackupStorageLocations(), informerFactory.Velero().V1().BackupStorageLocations(),
informerFactory.Velero().V1().Backups(), informerFactory.Velero().V1().Backups(),
func(logrus.FieldLogger) plugin.Manager { return pluginManager }, func(logrus.FieldLogger) clientmgmt.Manager { return pluginManager },
velerotest.NewLogger(), velerotest.NewLogger(),
).(*downloadRequestController) ).(*downloadRequestController)
) )

View File

@@ -40,7 +40,7 @@ import (
listers "github.com/heptio/velero/pkg/generated/listers/velero/v1" listers "github.com/heptio/velero/pkg/generated/listers/velero/v1"
"github.com/heptio/velero/pkg/metrics" "github.com/heptio/velero/pkg/metrics"
"github.com/heptio/velero/pkg/persistence" "github.com/heptio/velero/pkg/persistence"
"github.com/heptio/velero/pkg/plugin" "github.com/heptio/velero/pkg/plugin/clientmgmt"
"github.com/heptio/velero/pkg/plugin/velero" "github.com/heptio/velero/pkg/plugin/velero"
"github.com/heptio/velero/pkg/restore" "github.com/heptio/velero/pkg/restore"
"github.com/heptio/velero/pkg/util/collections" "github.com/heptio/velero/pkg/util/collections"
@@ -87,7 +87,7 @@ type restoreController struct {
defaultBackupLocation string defaultBackupLocation string
metrics *metrics.ServerMetrics metrics *metrics.ServerMetrics
newPluginManager func(logger logrus.FieldLogger) plugin.Manager newPluginManager func(logger logrus.FieldLogger) clientmgmt.Manager
newBackupStore func(*api.BackupStorageLocation, persistence.ObjectStoreGetter, logrus.FieldLogger) (persistence.BackupStore, error) newBackupStore func(*api.BackupStorageLocation, persistence.ObjectStoreGetter, logrus.FieldLogger) (persistence.BackupStore, error)
} }
@@ -106,7 +106,7 @@ func NewRestoreController(
snapshotLocationInformer informers.VolumeSnapshotLocationInformer, snapshotLocationInformer informers.VolumeSnapshotLocationInformer,
logger logrus.FieldLogger, logger logrus.FieldLogger,
restoreLogLevel logrus.Level, restoreLogLevel logrus.Level,
newPluginManager func(logrus.FieldLogger) plugin.Manager, newPluginManager func(logrus.FieldLogger) clientmgmt.Manager,
defaultBackupLocation string, defaultBackupLocation string,
metrics *metrics.ServerMetrics, metrics *metrics.ServerMetrics,
) Interface { ) Interface {
@@ -285,7 +285,7 @@ type backupInfo struct {
backupStore persistence.BackupStore backupStore persistence.BackupStore
} }
func (c *restoreController) validateAndComplete(restore *api.Restore, pluginManager plugin.Manager) backupInfo { func (c *restoreController) validateAndComplete(restore *api.Restore, pluginManager clientmgmt.Manager) backupInfo {
// add non-restorable resources to restore's excluded resources // add non-restorable resources to restore's excluded resources
excludedResources := sets.NewString(restore.Spec.ExcludedResources...) excludedResources := sets.NewString(restore.Spec.ExcludedResources...)
for _, nonrestorable := range nonRestorableResources { for _, nonrestorable := range nonRestorableResources {
@@ -409,7 +409,7 @@ func mostRecentCompletedBackup(backups []*api.Backup) *api.Backup {
// fetchBackupInfo checks the backup lister for a backup that matches the given name. If it doesn't // fetchBackupInfo checks the backup lister for a backup that matches the given name. If it doesn't
// find it, it returns an error. // find it, it returns an error.
func (c *restoreController) fetchBackupInfo(backupName string, pluginManager plugin.Manager) (backupInfo, error) { func (c *restoreController) fetchBackupInfo(backupName string, pluginManager clientmgmt.Manager) (backupInfo, error) {
backup, err := c.backupLister.Backups(c.namespace).Get(backupName) backup, err := c.backupLister.Backups(c.namespace).Get(backupName)
if err != nil { if err != nil {
return backupInfo{}, err return backupInfo{}, err
@@ -435,7 +435,7 @@ func (c *restoreController) runRestore(
restore *api.Restore, restore *api.Restore,
actions []velero.RestoreItemAction, actions []velero.RestoreItemAction,
info backupInfo, info backupInfo,
pluginManager plugin.Manager, pluginManager clientmgmt.Manager,
) (restoreResult, error) { ) (restoreResult, error) {
var restoreWarnings, restoreErrors api.RestoreResult var restoreWarnings, restoreErrors api.RestoreResult
var restoreFailure error var restoreFailure error

View File

@@ -43,7 +43,7 @@ import (
"github.com/heptio/velero/pkg/metrics" "github.com/heptio/velero/pkg/metrics"
"github.com/heptio/velero/pkg/persistence" "github.com/heptio/velero/pkg/persistence"
persistencemocks "github.com/heptio/velero/pkg/persistence/mocks" persistencemocks "github.com/heptio/velero/pkg/persistence/mocks"
"github.com/heptio/velero/pkg/plugin" "github.com/heptio/velero/pkg/plugin/clientmgmt"
pluginmocks "github.com/heptio/velero/pkg/plugin/mocks" pluginmocks "github.com/heptio/velero/pkg/plugin/mocks"
"github.com/heptio/velero/pkg/plugin/velero" "github.com/heptio/velero/pkg/plugin/velero"
"github.com/heptio/velero/pkg/restore" "github.com/heptio/velero/pkg/restore"
@@ -110,7 +110,7 @@ func TestFetchBackupInfo(t *testing.T) {
sharedInformers.Velero().V1().VolumeSnapshotLocations(), sharedInformers.Velero().V1().VolumeSnapshotLocations(),
logger, logger,
logrus.InfoLevel, logrus.InfoLevel,
func(logrus.FieldLogger) plugin.Manager { return pluginManager }, func(logrus.FieldLogger) clientmgmt.Manager { return pluginManager },
"default", "default",
metrics.NewServerMetrics(), metrics.NewServerMetrics(),
).(*restoreController) ).(*restoreController)
@@ -408,7 +408,7 @@ func TestProcessRestore(t *testing.T) {
sharedInformers.Velero().V1().VolumeSnapshotLocations(), sharedInformers.Velero().V1().VolumeSnapshotLocations(),
logger, logger,
logrus.InfoLevel, logrus.InfoLevel,
func(logrus.FieldLogger) plugin.Manager { return pluginManager }, func(logrus.FieldLogger) clientmgmt.Manager { return pluginManager },
"default", "default",
metrics.NewServerMetrics(), metrics.NewServerMetrics(),
).(*restoreController) ).(*restoreController)

View File

@@ -13,7 +13,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package plugin
// Package clientmgmt contains the plugin client for Velero.
package clientmgmt
import ( import (
"os" "os"

View File

@@ -13,7 +13,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package plugin
package clientmgmt
import ( import (
"os" "os"

View File

@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package plugin package clientmgmt
import ( import (
"fmt" "fmt"

View File

@@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package plugin package clientmgmt
import ( import (
"testing" "testing"

View File

@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package plugin package clientmgmt
import ( import (
"sync" "sync"

View File

@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package plugin package clientmgmt
import ( import (
"fmt" "fmt"

View File

@@ -13,7 +13,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package plugin
package clientmgmt
import ( import (
plugin "github.com/hashicorp/go-plugin" plugin "github.com/hashicorp/go-plugin"

View File

@@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package plugin package clientmgmt
import ( import (
"testing" "testing"

View File

@@ -13,7 +13,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package plugin
package clientmgmt
import ( import (
"fmt" "fmt"

View File

@@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package plugin package clientmgmt
import ( import (
"os" "os"

View File

@@ -13,7 +13,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package plugin
package clientmgmt
import ( import (
"github.com/pkg/errors" "github.com/pkg/errors"

View File

@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package plugin package clientmgmt
import ( import (
"testing" "testing"

View File

@@ -13,7 +13,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package plugin
package clientmgmt
import ( import (
"github.com/pkg/errors" "github.com/pkg/errors"

View File

@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package plugin package clientmgmt
import ( import (
"testing" "testing"

View File

@@ -13,7 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package plugin package clientmgmt
import ( import (
"reflect" "reflect"

View File

@@ -13,7 +13,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package plugin
package clientmgmt
import ( import (
"io" "io"

View File

@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package plugin package clientmgmt
import ( import (
"io/ioutil" "io/ioutil"

View File

@@ -13,7 +13,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package plugin
package clientmgmt
import ( import (
"sync" "sync"

View File

@@ -13,7 +13,8 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package plugin
package clientmgmt
import ( import (
"github.com/pkg/errors" "github.com/pkg/errors"

View File

@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package plugin package clientmgmt
import ( import (
"testing" "testing"

View File

@@ -18,7 +18,7 @@ package mocks
import logrus "github.com/sirupsen/logrus" import logrus "github.com/sirupsen/logrus"
import mock "github.com/stretchr/testify/mock" import mock "github.com/stretchr/testify/mock"
import plugin "github.com/heptio/velero/pkg/plugin" import "github.com/heptio/velero/pkg/plugin/clientmgmt"
// ProcessFactory is an autogenerated mock type for the ProcessFactory type // ProcessFactory is an autogenerated mock type for the ProcessFactory type
type ProcessFactory struct { type ProcessFactory struct {
@@ -26,15 +26,15 @@ type ProcessFactory struct {
} }
// newProcess provides a mock function with given fields: command, logger, logLevel // newProcess provides a mock function with given fields: command, logger, logLevel
func (_m *ProcessFactory) newProcess(command string, logger logrus.FieldLogger, logLevel logrus.Level) (plugin.Process, error) { func (_m *ProcessFactory) newProcess(command string, logger logrus.FieldLogger, logLevel logrus.Level) (clientmgmt.Process, error) {
ret := _m.Called(command, logger, logLevel) ret := _m.Called(command, logger, logLevel)
var r0 plugin.Process var r0 clientmgmt.Process
if rf, ok := ret.Get(0).(func(string, logrus.FieldLogger, logrus.Level) plugin.Process); ok { if rf, ok := ret.Get(0).(func(string, logrus.FieldLogger, logrus.Level) clientmgmt.Process); ok {
r0 = rf(command, logger, logLevel) r0 = rf(command, logger, logLevel)
} else { } else {
if ret.Get(0) != nil { if ret.Get(0) != nil {
r0 = ret.Get(0).(plugin.Process) r0 = ret.Get(0).(clientmgmt.Process)
} }
} }