Merge pull request #126683 from aojea/cidr_strategy

status writers are supposed to be constrained to modifying the status stanza
This commit is contained in:
Kubernetes Prow Robot 2024-08-14 08:03:18 -07:00 committed by GitHub
commit b6b7abc871
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -19,6 +19,7 @@ package servicecidr
import (
"context"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/validation/field"
"k8s.io/apiserver/pkg/registry/rest"
@ -144,6 +145,7 @@ func (serviceCIDRStatusStrategy) PrepareForUpdate(ctx context.Context, obj, old
oldServiceCIDR := old.(*networking.ServiceCIDR)
// status changes are not allowed to update spec
newServiceCIDR.Spec = oldServiceCIDR.Spec
metav1.ResetObjectMetaForStatus(&newServiceCIDR.ObjectMeta, &oldServiceCIDR.ObjectMeta)
}
// ValidateUpdate is the default update validation for an end user updating status