From dbfdd074d0f443670f01f353f483f8414f4b821f Mon Sep 17 00:00:00 2001 From: Antonio Ojea Date: Sat, 29 Jun 2024 10:06:00 +0000 Subject: [PATCH] update networking strategy and remove hardcode field on the test --- pkg/registry/networking/servicecidr/strategy.go | 6 ++++++ pkg/registry/networking/servicecidr/strategy_test.go | 9 --------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/pkg/registry/networking/servicecidr/strategy.go b/pkg/registry/networking/servicecidr/strategy.go index 229e8ef25c4..210f56f4355 100644 --- a/pkg/registry/networking/servicecidr/strategy.go +++ b/pkg/registry/networking/servicecidr/strategy.go @@ -53,6 +53,9 @@ func (serviceCIDRStrategy) NamespaceScoped() bool { // and should not be modified by the user. func (serviceCIDRStrategy) GetResetFields() map[fieldpath.APIVersion]*fieldpath.Set { fields := map[fieldpath.APIVersion]*fieldpath.Set{ + "networking/v1beta1": fieldpath.NewSet( + fieldpath.MakePathOrDie("status"), + ), "networking/v1alpha1": fieldpath.NewSet( fieldpath.MakePathOrDie("status"), ), @@ -125,6 +128,9 @@ var StatusStrategy = serviceCIDRStatusStrategy{Strategy} // and should not be modified by the user. func (serviceCIDRStatusStrategy) GetResetFields() map[fieldpath.APIVersion]*fieldpath.Set { fields := map[fieldpath.APIVersion]*fieldpath.Set{ + "networking/v1beta1": fieldpath.NewSet( + fieldpath.MakePathOrDie("spec"), + ), "networking/v1alpha1": fieldpath.NewSet( fieldpath.MakePathOrDie("spec"), ), diff --git a/pkg/registry/networking/servicecidr/strategy_test.go b/pkg/registry/networking/servicecidr/strategy_test.go index f54e381555f..b9ecd0eaa15 100644 --- a/pkg/registry/networking/servicecidr/strategy_test.go +++ b/pkg/registry/networking/servicecidr/strategy_test.go @@ -43,10 +43,6 @@ func TestServiceCIDRStrategy(t *testing.T) { t.Errorf("Expected ServiceCIDR to be cluster-scoped") } - resetFields := Strategy.GetResetFields() - if len(resetFields) != 1 { - t.Errorf("ResetFields should have 1 element, but have %d", len(resetFields)) - } obj := &networking.ServiceCIDR{Spec: networking.ServiceCIDRSpec{CIDRs: []string{"bad cidr"}}} errors := Strategy.Validate(context.TODO(), obj) @@ -64,11 +60,6 @@ func TestServiceCIDRStrategy(t *testing.T) { } func TestServiceCIDRStatusStrategy(t *testing.T) { - resetFields := StatusStrategy.GetResetFields() - if len(resetFields) != 1 { - t.Errorf("ResetFields should have 1 element, but have %d", len(resetFields)) - } - oldObj := &networking.ServiceCIDR{Spec: networking.ServiceCIDRSpec{}} newObj := &networking.ServiceCIDR{ Spec: networking.ServiceCIDRSpec{