Skip to content

Commit

Permalink
Allow updates to the extensions.BackupEntry.Spec.Region field (garden…
Browse files Browse the repository at this point in the history
  • Loading branch information
plkokanov authored and Kristiyan Gostev committed Jul 5, 2022
1 parent 0581781 commit 1df4eb2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
1 change: 0 additions & 1 deletion pkg/apis/extensions/validation/backupentry.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ func ValidateBackupEntrySpecUpdate(new, old *extensionsv1alpha1.BackupEntrySpec,
}

allErrs = append(allErrs, apivalidation.ValidateImmutableField(new.Type, old.Type, fldPath.Child("type"))...)
allErrs = append(allErrs, apivalidation.ValidateImmutableField(new.Region, old.Region, fldPath.Child("region"))...)

return allErrs
}
Expand Down
25 changes: 19 additions & 6 deletions pkg/apis/extensions/validation/backupentry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,20 +93,15 @@ var _ = Describe("BackupEntry validation tests", func() {
}))))
})

It("should prevent updating the type or region", func() {
It("should prevent updating the type", func() {
newBackupEntry := prepareBackupEntryForUpdate(be)
newBackupEntry.Spec.Type = "changed-type"
newBackupEntry.Spec.Region = "changed-region"
newBackupEntry.Spec.BucketName = "changed-bucket-name"

errorList := ValidateBackupEntryUpdate(newBackupEntry, be)

Expect(errorList).To(ConsistOf(PointTo(MatchFields(IgnoreExtras, Fields{
"Type": Equal(field.ErrorTypeInvalid),
"Field": Equal("spec.type"),
})), PointTo(MatchFields(IgnoreExtras, Fields{
"Type": Equal(field.ErrorTypeInvalid),
"Field": Equal("spec.region"),
}))))
})

Expand All @@ -118,6 +113,24 @@ var _ = Describe("BackupEntry validation tests", func() {

Expect(errorList).To(BeEmpty())
})

It("should allow updating the name of the backup bucket", func() {
newBackupEntry := prepareBackupEntryForUpdate(be)
newBackupEntry.Spec.BucketName = "changed-bucket-name"

errorList := ValidateBackupEntryUpdate(newBackupEntry, be)

Expect(errorList).To(BeEmpty())
})

It("should allow updating the region", func() {
newBackupEntry := prepareBackupEntryForUpdate(be)
newBackupEntry.Spec.Region = "changed-region"

errorList := ValidateBackupEntryUpdate(newBackupEntry, be)

Expect(errorList).To(BeEmpty())
})
})
})

Expand Down

0 comments on commit 1df4eb2

Please sign in to comment.