Skip to content

Commit

Permalink
fix: if bakcup config have backup method, don't need to set backup me…
Browse files Browse the repository at this point in the history
…thod in flag
  • Loading branch information
fengluodb committed Oct 12, 2023
1 parent 1cf78a3 commit ff0c4f7
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion internal/cli/cmd/cluster/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -1403,10 +1403,14 @@ func (o *CreateOptions) buildBackupConfig(cls *appsv1alpha1.Cluster) error {

// must set backup method when set backup config in cli
if len(flags) > 0 {
methodRequiredErr := fmt.Errorf("backup method is required, use --backup-method to specify one, run \"kbcli cd describe cd-name\" to show all backup methods")
var methodRequiredErr error
if o.BackupConfig == nil {
o.BackupConfig = &appsv1alpha1.ClusterBackup{}
}
// if the backup method is not exist and the user does not set the backup method, return error
if o.BackupConfig.Method == "" {
methodRequiredErr = fmt.Errorf("backup method is required, please use --backup-method to set it")
}

// if the flag is set by user, use the flag value
for _, flag := range flags {
Expand Down

0 comments on commit ff0c4f7

Please sign in to comment.