add default restic flag to backup create cli

Signed-off-by: Ashish Amarnath <ashisham@vmware.com>
This commit is contained in:
Ashish Amarnath
2020-06-04 15:16:05 -07:00
parent 69cceb0d7e
commit f34aab251e
2 changed files with 13 additions and 0 deletions

View File

@@ -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

View File

@@ -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()