Update reset fields to match current field wiping behavior

This commit is contained in:
Joe Betz
2026-03-12 20:14:52 -04:00
parent 92ddb3a367
commit 67a23785ee
3 changed files with 17 additions and 4 deletions

View File

@@ -56,10 +56,14 @@ func (serviceCIDRStrategy) NamespaceScoped() bool {
func (serviceCIDRStrategy) GetResetFields() map[fieldpath.APIVersion]*fieldpath.Set {
fields := map[fieldpath.APIVersion]*fieldpath.Set{
"networking.k8s.io/v1": fieldpath.NewSet(
fieldpath.MakePathOrDie("status"),
// Disabled to match PrepareForCreate/PrepareForUpdate, which do not wipe fields
// https://github.com/kubernetes/kubernetes/issues/137680
// fieldpath.MakePathOrDie("status"),
),
"networking.k8s.io/v1beta1": fieldpath.NewSet(
fieldpath.MakePathOrDie("status"),
// Disabled to match PrepareForCreate/PrepareForUpdate, which do not wipe fields
// https://github.com/kubernetes/kubernetes/issues/137680
// fieldpath.MakePathOrDie("status"),
),
}
return fields
@@ -130,9 +134,11 @@ var StatusStrategy = serviceCIDRStatusStrategy{Strategy}
func (serviceCIDRStatusStrategy) GetResetFields() map[fieldpath.APIVersion]*fieldpath.Set {
fields := map[fieldpath.APIVersion]*fieldpath.Set{
"networking.k8s.io/v1": fieldpath.NewSet(
fieldpath.MakePathOrDie("metadata"),
fieldpath.MakePathOrDie("spec"),
),
"networking.k8s.io/v1beta1": fieldpath.NewSet(
fieldpath.MakePathOrDie("metadata"),
fieldpath.MakePathOrDie("spec"),
),
}

View File

@@ -56,6 +56,7 @@ func (a statusStrategy) GetResetFields() map[fieldpath.APIVersion]*fieldpath.Set
// we might need a mechanism that is the inverse of resetFields where
// you specify only the fields to be kept rather than the fields to be wiped
// that way you could wipe everything but the status in this case.
fieldpath.MakePathOrDie("metadata"),
fieldpath.MakePathOrDie("spec"),
),
}

View File

@@ -252,11 +252,17 @@ func (statusStrategy) NamespaceScoped() bool {
func (statusStrategy) GetResetFields() map[fieldpath.APIVersion]*fieldpath.Set {
fields := map[fieldpath.APIVersion]*fieldpath.Set{
"apiextensions.k8s.io/v1": fieldpath.NewSet(
fieldpath.MakePathOrDie("metadata"),
// Disabled to match PrepareForUpdate, which do not wipe metadata
// https://github.com/kubernetes/kubernetes/issues/137681
// fieldpath.MakePathOrDie("metadata"),
fieldpath.MakePathOrDie("spec"),
),
"apiextensions.k8s.io/v1beta1": fieldpath.NewSet(
fieldpath.MakePathOrDie("metadata"),
// Disabled to match PrepareForUpdate, which do not wipe metadata
// https://github.com/kubernetes/kubernetes/issues/137681
// fieldpath.MakePathOrDie("metadata"),
fieldpath.MakePathOrDie("spec"),
),
}