Skip to content

Commit ff536ee

Browse files
authored
Merge pull request kubernetes#87602 from wojtek-t/cleanup_immutable_validation
Cleanup validation for immutable secrets/configmaps
2 parents 608ac4e + 39f6c78 commit ff536ee

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pkg/apis/core/validation/validation.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5006,7 +5006,7 @@ func ValidateSecretUpdate(newSecret, oldSecret *core.Secret) field.ErrorList {
50065006

50075007
allErrs = append(allErrs, ValidateImmutableField(newSecret.Type, oldSecret.Type, field.NewPath("type"))...)
50085008
if oldSecret.Immutable != nil && *oldSecret.Immutable {
5009-
if !reflect.DeepEqual(newSecret.Immutable, oldSecret.Immutable) {
5009+
if newSecret.Immutable == nil || !*newSecret.Immutable {
50105010
allErrs = append(allErrs, field.Forbidden(field.NewPath("immutable"), "field is immutable when `immutable` is set"))
50115011
}
50125012
if !reflect.DeepEqual(newSecret.Data, oldSecret.Data) {
@@ -5063,7 +5063,7 @@ func ValidateConfigMapUpdate(newCfg, oldCfg *core.ConfigMap) field.ErrorList {
50635063
allErrs = append(allErrs, ValidateObjectMetaUpdate(&newCfg.ObjectMeta, &oldCfg.ObjectMeta, field.NewPath("metadata"))...)
50645064

50655065
if oldCfg.Immutable != nil && *oldCfg.Immutable {
5066-
if !reflect.DeepEqual(newCfg.Immutable, oldCfg.Immutable) {
5066+
if newCfg.Immutable == nil || !*newCfg.Immutable {
50675067
allErrs = append(allErrs, field.Forbidden(field.NewPath("immutable"), "field is immutable when `immutable` is set"))
50685068
}
50695069
if !reflect.DeepEqual(newCfg.Data, oldCfg.Data) {

0 commit comments

Comments
 (0)