From e24248e07a785131e44212bb6d0dc108526a56f6 Mon Sep 17 00:00:00 2001 From: Steve Kriss Date: Wed, 10 Oct 2018 15:01:52 -0600 Subject: [PATCH] add --volume-snapshot-locations flag to ark backup create Signed-off-by: Steve Kriss --- pkg/cmd/cli/backup/create.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkg/cmd/cli/backup/create.go b/pkg/cmd/cli/backup/create.go index 837a87db7..5d853142b 100644 --- a/pkg/cmd/cli/backup/create.go +++ b/pkg/cmd/cli/backup/create.go @@ -70,6 +70,7 @@ type CreateOptions struct { IncludeClusterResources flag.OptionalBool Wait bool StorageLocation string + SnapshotLocations []string client arkclient.Interface } @@ -92,6 +93,7 @@ func (o *CreateOptions) BindFlags(flags *pflag.FlagSet) { flags.Var(&o.ExcludeResources, "exclude-resources", "resources to exclude from the backup, formatted as resource.group, such as storageclasses.storage.k8s.io") flags.Var(&o.Labels, "labels", "labels to apply to the backup") flags.StringVar(&o.StorageLocation, "storage-location", "", "location in which to store the backup") + flags.StringSliceVar(&o.SnapshotLocations, "volume-snapshot-locations", o.SnapshotLocations, "list of locations (at most one per provider) where volume snapshots should be stored") flags.VarP(&o.Selector, "selector", "l", "only back up resources matching this label selector") f := flags.VarPF(&o.SnapshotVolumes, "snapshot-volumes", "", "take snapshots of PersistentVolumes as part of the backup") // this allows the user to just specify "--snapshot-volumes" as shorthand for "--snapshot-volumes=true" @@ -119,6 +121,12 @@ func (o *CreateOptions) Validate(c *cobra.Command, args []string, f client.Facto } } + for _, loc := range o.SnapshotLocations { + if _, err := o.client.ArkV1().VolumeSnapshotLocations(f.Namespace()).Get(loc, metav1.GetOptions{}); err != nil { + return err + } + } + return nil } @@ -150,6 +158,7 @@ func (o *CreateOptions) Run(c *cobra.Command, f client.Factory) error { TTL: metav1.Duration{Duration: o.TTL}, IncludeClusterResources: o.IncludeClusterResources.Value, StorageLocation: o.StorageLocation, + VolumeSnapshotLocations: o.SnapshotLocations, }, }