mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-09-21 07:24:19 +00:00
Replace NewObjectBackupStore with interface (#3329)
In preparation for modifying the instantiation of `BackupStores` to be able to load credentials, change the function `NewObjectBackupStore` to be an interface that is passed in to all controllers. Previously, the function to get a new backup store was configurable but for many controllers was fixed to use `NewObjectBackupStore`. This change introduces an interface for getting the backup store and wraps the functionality from `NewObjectBackupStore` in a type which implements this interface. This will allow more flexibility when introducing credentials for a specific backup store as it will allow us to create a new `ObjectBackupStoreGetter` type which can be configured to add credentials config when creating the ObjectBackupStore without needing to change the API used by the controllers. Signed-off-by: Bridget McErlean <bmcerlean@vmware.com>
This commit is contained in:
@@ -80,7 +80,7 @@ type backupController struct {
|
||||
snapshotLocationLister velerov1listers.VolumeSnapshotLocationLister
|
||||
defaultSnapshotLocations map[string]string
|
||||
metrics *metrics.ServerMetrics
|
||||
newBackupStore func(*velerov1api.BackupStorageLocation, persistence.ObjectStoreGetter, logrus.FieldLogger) (persistence.BackupStore, error)
|
||||
backupStoreGetter persistence.ObjectBackupStoreGetter
|
||||
formatFlag logging.Format
|
||||
volumeSnapshotLister snapshotv1beta1listers.VolumeSnapshotLister
|
||||
volumeSnapshotContentLister snapshotv1beta1listers.VolumeSnapshotContentLister
|
||||
@@ -105,6 +105,7 @@ func NewBackupController(
|
||||
formatFlag logging.Format,
|
||||
volumeSnapshotLister snapshotv1beta1listers.VolumeSnapshotLister,
|
||||
volumeSnapshotContentLister snapshotv1beta1listers.VolumeSnapshotContentLister,
|
||||
backupStoreGetter persistence.ObjectBackupStoreGetter,
|
||||
) Interface {
|
||||
c := &backupController{
|
||||
genericController: newGenericController(Backup, logger),
|
||||
@@ -126,7 +127,7 @@ func NewBackupController(
|
||||
formatFlag: formatFlag,
|
||||
volumeSnapshotLister: volumeSnapshotLister,
|
||||
volumeSnapshotContentLister: volumeSnapshotContentLister,
|
||||
newBackupStore: persistence.NewObjectBackupStore,
|
||||
backupStoreGetter: backupStoreGetter,
|
||||
}
|
||||
|
||||
c.syncHandler = c.processBackup
|
||||
@@ -570,7 +571,7 @@ func (c *backupController) runBackup(backup *pkgbackup.Request) error {
|
||||
}
|
||||
|
||||
backupLog.Info("Setting up backup store to check for backup existence")
|
||||
backupStore, err := c.newBackupStore(backup.StorageLocation, pluginManager, backupLog)
|
||||
backupStore, err := c.backupStoreGetter.Get(backup.StorageLocation, pluginManager, backupLog)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -651,7 +652,7 @@ func (c *backupController) runBackup(backup *pkgbackup.Request) error {
|
||||
// re-instantiate the backup store because credentials could have changed since the original
|
||||
// instantiation, if this was a long-running backup
|
||||
backupLog.Info("Setting up backup store to persist the backup")
|
||||
backupStore, err = c.newBackupStore(backup.StorageLocation, pluginManager, backupLog)
|
||||
backupStore, err = c.backupStoreGetter.Get(backup.StorageLocation, pluginManager, backupLog)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user