From a3b689265ef485b41865b1c252e7869ff17bc2cc Mon Sep 17 00:00:00 2001 From: Shubham Pampattiwar Date: Tue, 24 Sep 2024 16:33:27 -0700 Subject: [PATCH] Remove mutiple single quotes from Velero backup.status.validationErrors field Signed-off-by: Shubham Pampattiwar update error message Signed-off-by: Shubham Pampattiwar (cherry picked from commit f15cde5dfd4ae089baea88c88e924931253428b7) --- pkg/controller/backup_controller.go | 4 ++-- pkg/controller/backup_controller_test.go | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/controller/backup_controller.go b/pkg/controller/backup_controller.go index a3cf54718e..52c69c381c 100644 --- a/pkg/controller/backup_controller.go +++ b/pkg/controller/backup_controller.go @@ -410,9 +410,9 @@ func (b *backupReconciler) prepareBackupRequest(backup *velerov1api.Backup, logg if apierrors.IsNotFound(err) { if serverSpecified { // TODO(2.0) remove this. For now, without mentioning "server default" it could be confusing trying to grasp where the default came from. - request.Status.ValidationErrors = append(request.Status.ValidationErrors, fmt.Sprintf("an existing backup storage location wasn't specified at backup creation time and the server default '%s' doesn't exist. Please address this issue (see `velero backup-location -h` for options) and create a new backup. Error: %v", request.Spec.StorageLocation, err)) + request.Status.ValidationErrors = append(request.Status.ValidationErrors, fmt.Sprintf("an existing backup storage location was not specified at backup creation time and the server default %s does not exist. Please address this issue (see `velero backup-location -h` for options) and create a new backup. Error: %v", request.Spec.StorageLocation, err)) } else { - request.Status.ValidationErrors = append(request.Status.ValidationErrors, fmt.Sprintf("an existing backup storage location wasn't specified at backup creation time and the default '%s' wasn't found. Please address this issue (see `velero backup-location -h` for options) and create a new backup. Error: %v", request.Spec.StorageLocation, err)) + request.Status.ValidationErrors = append(request.Status.ValidationErrors, fmt.Sprintf("an existing backup storage location was not specified at backup creation time and the default %s was not found. Please address this issue (see `velero backup-location -h` for options) and create a new backup. Error: %v", request.Spec.StorageLocation, err)) } } else { request.Status.ValidationErrors = append(request.Status.ValidationErrors, fmt.Sprintf("error getting backup storage location: %v", err)) diff --git a/pkg/controller/backup_controller_test.go b/pkg/controller/backup_controller_test.go index 576b536472..32e82cc3bc 100644 --- a/pkg/controller/backup_controller_test.go +++ b/pkg/controller/backup_controller_test.go @@ -242,7 +242,7 @@ func TestProcessBackupValidationFailures(t *testing.T) { { name: "non-existent backup location fails validation", backup: defaultBackup().StorageLocation("nonexistent").Result(), - expectedErrs: []string{"an existing backup storage location wasn't specified at backup creation time and the default 'nonexistent' wasn't found. Please address this issue (see `velero backup-location -h` for options) and create a new backup. Error: backupstoragelocations.velero.io \"nonexistent\" not found"}, + expectedErrs: []string{"an existing backup storage location was not specified at backup creation time and the default nonexistent was not found. Please address this issue (see `velero backup-location -h` for options) and create a new backup. Error: backupstoragelocations.velero.io \"nonexistent\" not found"}, }, { name: "backup for read-only backup location fails validation", @@ -398,7 +398,7 @@ func Test_prepareBackupRequest_BackupStorageLocation(t *testing.T) { backupLocationInAPIServer: nil, defaultBackupLocationInAPIServer: nil, expectedSuccess: false, - expectedValidationError: "an existing backup storage location wasn't specified at backup creation time and the default 'test-backup-location' wasn't found. Please address this issue (see `velero backup-location -h` for options) and create a new backup. Error: backupstoragelocations.velero.io \"test-backup-location\" not found", + expectedValidationError: "an existing backup storage location was not specified at backup creation time and the default test-backup-location was not found. Please address this issue (see `velero backup-location -h` for options) and create a new backup. Error: backupstoragelocations.velero.io \"test-backup-location\" not found", }, { name: "Using default BackupLocation and it can be found in ApiServer", @@ -416,7 +416,7 @@ func Test_prepareBackupRequest_BackupStorageLocation(t *testing.T) { backupLocationInAPIServer: nil, defaultBackupLocationInAPIServer: nil, expectedSuccess: false, - expectedValidationError: fmt.Sprintf("an existing backup storage location wasn't specified at backup creation time and the server default '%s' doesn't exist. Please address this issue (see `velero backup-location -h` for options) and create a new backup. Error: backupstoragelocations.velero.io \"%s\" not found", defaultBackupLocation, defaultBackupLocation), + expectedValidationError: fmt.Sprintf("an existing backup storage location was not specified at backup creation time and the server default %s does not exist. Please address this issue (see `velero backup-location -h` for options) and create a new backup. Error: backupstoragelocations.velero.io \"%s\" not found", defaultBackupLocation, defaultBackupLocation), }, }