Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions pkg/cmd/cluster/dataprotection.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,21 @@ func (o *CreateBackupOptions) Validate() error {
if o.BackupSpec.BackupMethod == "" {
return fmt.Errorf("backup method can not be empty, you can specify it by --method")
}

// check if the backup method exists in backup policy
exist, availableMethods := false, make([]string, 0)
for _, method := range backupPolicy.Spec.BackupMethods {
availableMethods = append(availableMethods, method.Name)
if o.BackupSpec.BackupMethod == method.Name {
exist = true
break
}
}
if !exist {
return fmt.Errorf("specified backup method %s does not exist in backup policy %s, available methods: [%s]\n",
o.BackupSpec.BackupMethod, backupPolicy.Name, strings.Join(availableMethods, ", "))
}

// TODO: check if pvc exists

// valid retention period
Expand Down