From f34aab251e68e3a8943e990ff85b4fcae8fe9c90 Mon Sep 17 00:00:00 2001 From: Ashish Amarnath Date: Thu, 4 Jun 2020 15:16:05 -0700 Subject: [PATCH] add default restic flag to backup create cli Signed-off-by: Ashish Amarnath --- pkg/builder/backup_builder.go | 6 ++++++ pkg/cmd/cli/backup/create.go | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/pkg/builder/backup_builder.go b/pkg/builder/backup_builder.go index 6d0b1dc68..c9cdedf61 100644 --- a/pkg/builder/backup_builder.go +++ b/pkg/builder/backup_builder.go @@ -128,6 +128,12 @@ func (b *BackupBuilder) SnapshotVolumes(val bool) *BackupBuilder { return b } +// DefaultRestic sets the Backup's "DefaultRestic" flag. +func (b *BackupBuilder) DefaultRestic(val bool) *BackupBuilder { + b.object.Spec.DefaultRestic = &val + return b +} + // Phase sets the Backup's phase. func (b *BackupBuilder) Phase(phase velerov1api.BackupPhase) *BackupBuilder { b.object.Status.Phase = phase diff --git a/pkg/cmd/cli/backup/create.go b/pkg/cmd/cli/backup/create.go index 2ba0986c9..ad6345a80 100644 --- a/pkg/cmd/cli/backup/create.go +++ b/pkg/cmd/cli/backup/create.go @@ -81,6 +81,7 @@ type CreateOptions struct { Name string TTL time.Duration SnapshotVolumes flag.OptionalBool + DefaultRestic flag.OptionalBool IncludeNamespaces flag.StringArray ExcludeNamespaces flag.StringArray IncludeResources flag.StringArray @@ -123,6 +124,9 @@ func (o *CreateOptions) BindFlags(flags *pflag.FlagSet) { f = flags.VarPF(&o.IncludeClusterResources, "include-cluster-resources", "", "include cluster-scoped resources in the backup") f.NoOptDefVal = "true" + + f = flags.VarPF(&o.DefaultRestic, "default-restic", "", "use restic by default to backup all pod volumes") + f.NoOptDefVal = "true" } // BindWait binds the wait flag separately so it is not called by other create @@ -295,6 +299,9 @@ func (o *CreateOptions) BuildBackup(namespace string) (*velerov1api.Backup, erro if o.IncludeClusterResources.Value != nil { backupBuilder.IncludeClusterResources(*o.IncludeClusterResources.Value) } + if o.DefaultRestic.Value != nil { + backupBuilder.DefaultRestic(*o.DefaultRestic.Value) + } } backup := backupBuilder.ObjectMeta(builder.WithLabelsMap(o.Labels.Data())).Result()