mirror of
https://github.com/vmware-tanzu/velero.git
synced 2026-09-19 06:26:44 +00:00
convert restorers to plugins
Signed-off-by: Steve Kriss <steve@heptio.com>
This commit is contained in:
@@ -27,6 +27,7 @@ import (
|
||||
"github.com/heptio/ark/pkg/cloudprovider/azure"
|
||||
"github.com/heptio/ark/pkg/cloudprovider/gcp"
|
||||
arkplugin "github.com/heptio/ark/pkg/plugin"
|
||||
"github.com/heptio/ark/pkg/restore"
|
||||
)
|
||||
|
||||
func NewCommand() *cobra.Command {
|
||||
@@ -44,8 +45,14 @@ func NewCommand() *cobra.Command {
|
||||
"azure": azure.NewBlockStore(),
|
||||
}
|
||||
|
||||
backupActions := map[string]backup.ItemAction{
|
||||
"backup_pv": backup.NewBackupPVAction(logger),
|
||||
backupItemActions := map[string]backup.ItemAction{
|
||||
"pv": backup.NewBackupPVAction(logger),
|
||||
}
|
||||
|
||||
restoreItemActions := map[string]restore.ItemAction{
|
||||
"job": restore.NewJobAction(logger),
|
||||
"pod": restore.NewPodAction(logger),
|
||||
"svc": restore.NewServiceAction(logger),
|
||||
}
|
||||
|
||||
c := &cobra.Command{
|
||||
@@ -86,13 +93,22 @@ func NewCommand() *cobra.Command {
|
||||
string(arkplugin.PluginKindBlockStore): arkplugin.NewBlockStorePlugin(blockStore),
|
||||
}
|
||||
case arkplugin.PluginKindBackupItemAction.String():
|
||||
action, found := backupActions[name]
|
||||
action, found := backupItemActions[name]
|
||||
if !found {
|
||||
logger.Fatalf("Unrecognized plugin name")
|
||||
}
|
||||
|
||||
serveConfig.Plugins = map[string]plugin.Plugin{
|
||||
arkplugin.PluginKindBackupItemAction.String(): arkplugin.NewBackupItemActionPlugin(action),
|
||||
kind: arkplugin.NewBackupItemActionPlugin(action),
|
||||
}
|
||||
case arkplugin.PluginKindRestoreItemAction.String():
|
||||
action, found := restoreItemActions[name]
|
||||
if !found {
|
||||
logger.Fatalf("Unrecognized plugin name")
|
||||
}
|
||||
|
||||
serveConfig.Plugins = map[string]plugin.Plugin{
|
||||
kind: arkplugin.NewRestoreItemActionPlugin(action),
|
||||
}
|
||||
default:
|
||||
logger.Fatalf("Unsupported plugin kind")
|
||||
|
||||
@@ -54,7 +54,6 @@ import (
|
||||
informers "github.com/heptio/ark/pkg/generated/informers/externalversions"
|
||||
"github.com/heptio/ark/pkg/plugin"
|
||||
"github.com/heptio/ark/pkg/restore"
|
||||
"github.com/heptio/ark/pkg/restore/restorers"
|
||||
"github.com/heptio/ark/pkg/util/kube"
|
||||
"github.com/heptio/ark/pkg/util/logging"
|
||||
)
|
||||
@@ -510,6 +509,7 @@ func (s *server) runControllers(config *api.Config) error {
|
||||
s.sharedInformerFactory.Ark().V1().Backups(),
|
||||
s.snapshotService != nil,
|
||||
s.logger,
|
||||
s.pluginManager,
|
||||
)
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
@@ -569,20 +569,11 @@ func newRestorer(
|
||||
kubeClient kubernetes.Interface,
|
||||
logger *logrus.Logger,
|
||||
) (restore.Restorer, error) {
|
||||
restorers := map[string]restorers.ResourceRestorer{
|
||||
"persistentvolumes": restorers.NewPersistentVolumeRestorer(snapshotService),
|
||||
"persistentvolumeclaims": restorers.NewPersistentVolumeClaimRestorer(),
|
||||
"services": restorers.NewServiceRestorer(),
|
||||
"namespaces": restorers.NewNamespaceRestorer(),
|
||||
"pods": restorers.NewPodRestorer(logger),
|
||||
"jobs": restorers.NewJobRestorer(logger),
|
||||
}
|
||||
|
||||
return restore.NewKubernetesRestorer(
|
||||
discoveryHelper,
|
||||
client.NewDynamicFactory(clientPool),
|
||||
restorers,
|
||||
backupService,
|
||||
snapshotService,
|
||||
resourcePriorities,
|
||||
backupClient,
|
||||
kubeClient.CoreV1().Namespaces(),
|
||||
|
||||
Reference in New Issue
Block a user