Skip to content

Commit

Permalink
update networking strategy and remove hardcode field on the test
Browse files Browse the repository at this point in the history
  • Loading branch information
aojea committed Jun 30, 2024
1 parent c1d06c0 commit dbfdd07
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
6 changes: 6 additions & 0 deletions pkg/registry/networking/servicecidr/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
),
Expand Down Expand Up @@ -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"),
),
Expand Down
9 changes: 0 additions & 9 deletions pkg/registry/networking/servicecidr/strategy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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{
Expand Down

0 comments on commit dbfdd07

Please sign in to comment.