mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-17 15:50:10 +00:00
move secret mutation from validation to prepareforupdate
This commit is contained in:
parent
555eba5651
commit
bd5b1e2d05
@ -5229,10 +5229,6 @@ func ValidateSecret(secret *core.Secret) field.ErrorList {
|
||||
func ValidateSecretUpdate(newSecret, oldSecret *core.Secret) field.ErrorList {
|
||||
allErrs := ValidateObjectMetaUpdate(&newSecret.ObjectMeta, &oldSecret.ObjectMeta, field.NewPath("metadata"))
|
||||
|
||||
if len(newSecret.Type) == 0 {
|
||||
newSecret.Type = oldSecret.Type
|
||||
}
|
||||
|
||||
allErrs = append(allErrs, ValidateImmutableField(newSecret.Type, oldSecret.Type, field.NewPath("type"))...)
|
||||
if oldSecret.Immutable != nil && *oldSecret.Immutable {
|
||||
if newSecret.Immutable == nil || !*newSecret.Immutable {
|
||||
|
@ -70,6 +70,12 @@ func (strategy) AllowCreateOnUpdate() bool {
|
||||
func (strategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
|
||||
newSecret := obj.(*api.Secret)
|
||||
oldSecret := old.(*api.Secret)
|
||||
|
||||
// this is weird, but consistent with what the validatedUpdate function used to do.
|
||||
if len(newSecret.Type) == 0 {
|
||||
newSecret.Type = oldSecret.Type
|
||||
}
|
||||
|
||||
dropDisabledFields(newSecret, oldSecret)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user