Move velero server side default backup location setting logic to server startup

Signed-off-by: Ming Qiu <mqiu@vmware.com>
This commit is contained in:
Ming Qiu
2023-12-19 05:43:29 +00:00
parent ea6c8ca127
commit 7d2be128ae
5 changed files with 88 additions and 32 deletions
+7 -1
View File
@@ -125,7 +125,13 @@ func (o *SetOptions) Run(c *cobra.Command, f client.Factory) error {
return errors.WithStack(err)
}
if len(defalutBSLs.Items) > 0 {
return errors.New("there is already a default backup storage location")
if len(defalutBSLs.Items) == 1 && defalutBSLs.Items[0].Name == o.Name {
// the default backup storage location is the one we want to set
// so we do not need to do anything
fmt.Printf("Backup storage location %q is already the default backup storage location.\n", o.Name)
return nil
}
return errors.New("there are already exist default backup storage locations, please unset them first")
}
}
} else {