Merge pull request #3172 from carlisia/c-bsl-imp

Improvements to BSL logic
This commit is contained in:
JenTing Hsiao
2020-12-16 23:16:36 +08:00
committed by GitHub
15 changed files with 101 additions and 78 deletions
+7 -8
View File
@@ -182,20 +182,19 @@ func (o *CreateOptions) Run(c *cobra.Command, f client.Factory) error {
if o.DefaultBackupStorageLocation {
// There is one and only one default backup storage location.
// Disable the origin default backup storage location.
// Disable any existing default backup storage location.
locations := new(velerov1api.BackupStorageLocationList)
if err := kbClient.List(context.Background(), locations, &kbclient.ListOptions{Namespace: f.Namespace()}); err != nil {
return errors.WithStack(err)
}
for _, location := range locations.Items {
if !location.Spec.Default {
continue
if location.Spec.Default {
location.Spec.Default = false
if err := kbClient.Update(context.Background(), &location, &kbclient.UpdateOptions{}); err != nil {
return errors.WithStack(err)
}
break
}
location.Spec.Default = false
if err := kbClient.Update(context.Background(), &location, &kbclient.UpdateOptions{}); err != nil {
return errors.WithStack(err)
}
break
}
}
+1
View File
@@ -57,6 +57,7 @@ func NewGetCommand(f client.Factory, use string) *cobra.Command {
if showDefaultOnly {
if location.Spec.Default {
locations.Items = append(locations.Items, *location)
break
}
} else {
locations.Items = append(locations.Items, *location)
+1 -1
View File
@@ -36,7 +36,7 @@ func NewSetCommand(f client.Factory, use string) *cobra.Command {
c := &cobra.Command{
Use: use + " NAME",
Short: "Set a backup storage location",
Short: "Set specific features for a backup storage location",
Args: cobra.ExactArgs(1),
Run: func(c *cobra.Command, args []string) {
cmd.CheckError(o.Complete(args, f))