Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
gnolong committed Dec 25, 2024
1 parent 31f1fd9 commit 79f44b6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
4 changes: 3 additions & 1 deletion pkg/dataprotection/restore/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,9 @@ func (r *RestoreManager) getBackupActionSetForContinuous(reqCtx intctrlutil.Requ
if err != nil {
return nil, err
}
backupItems := append(fullBackupItems, incrementalBackupItems...)
backupItems := []dpv1alpha1.Backup{}
backupItems = append(backupItems, fullBackupItems...)
backupItems = append(backupItems, incrementalBackupItems...)
// sort by completed time in descending order
sort.Slice(backupItems, func(i, j int) bool {
i, j = j, i
Expand Down
17 changes: 10 additions & 7 deletions pkg/dataprotection/restore/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -434,24 +434,27 @@ func ValidateParentBackupSet(parentBackupSet *BackupActionSet, backupSet *Backup
parentBackup.Spec.BackupPolicyName, backup.Spec.BackupPolicyName)
}
// validate parent backup method
if parentBackupSet.ActionSet != nil && parentBackupSet.ActionSet.Spec.BackupType == dpv1alpha1.BackupTypeIncremental {
var parentBackupType dpv1alpha1.BackupType
if parentBackupSet.ActionSet != nil {
parentBackupType = parentBackupSet.ActionSet.Spec.BackupType
}
switch parentBackupType {
case dpv1alpha1.BackupTypeIncremental:
if parentBackup.Spec.BackupMethod != backup.Spec.BackupMethod {
return fmt.Errorf(`the parent incremental backup method "%s" is not the same with the child backup method "%s"`,
parentBackup.Spec.BackupMethod, backup.Spec.BackupMethod)
}
} else if parentBackupSet.ActionSet != nil && parentBackupSet.ActionSet.Spec.BackupType == dpv1alpha1.BackupTypeFull {
case dpv1alpha1.BackupTypeFull:
if parentBackup.Spec.BackupMethod != backup.Status.BackupMethod.CompatibleMethod {
return fmt.Errorf(`the parent full backup method "%s" is not compatible with the child backup method "%s"`,
parentBackup.Spec.BackupMethod, backup.Spec.BackupMethod)
}
} else {
return fmt.Errorf(`the parent backup "%s" is not incremental or full backup`,
parentBackup.Name)
default:
return fmt.Errorf(`the parent backup "%s" is not incremental or full backup`, parentBackup.Name)
}
// validate parent backup end time
if !utils.CompareWithBackupStopTime(*parentBackup, *backup) {
return fmt.Errorf(`the parent backup "%s" is not before the child backup "%s"`,
parentBackup.Name, backup.Name)
return fmt.Errorf(`the parent backup "%s" is not before the child backup "%s"`, parentBackup.Name, backup.Name)
}
return nil
}
Expand Down

0 comments on commit 79f44b6

Please sign in to comment.