Skip to content

Commit dbfdd07

Browse files
committed
update networking strategy and remove hardcode field on the test
1 parent c1d06c0 commit dbfdd07

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

pkg/registry/networking/servicecidr/strategy.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ func (serviceCIDRStrategy) NamespaceScoped() bool {
5353
// and should not be modified by the user.
5454
func (serviceCIDRStrategy) GetResetFields() map[fieldpath.APIVersion]*fieldpath.Set {
5555
fields := map[fieldpath.APIVersion]*fieldpath.Set{
56+
"networking/v1beta1": fieldpath.NewSet(
57+
fieldpath.MakePathOrDie("status"),
58+
),
5659
"networking/v1alpha1": fieldpath.NewSet(
5760
fieldpath.MakePathOrDie("status"),
5861
),
@@ -125,6 +128,9 @@ var StatusStrategy = serviceCIDRStatusStrategy{Strategy}
125128
// and should not be modified by the user.
126129
func (serviceCIDRStatusStrategy) GetResetFields() map[fieldpath.APIVersion]*fieldpath.Set {
127130
fields := map[fieldpath.APIVersion]*fieldpath.Set{
131+
"networking/v1beta1": fieldpath.NewSet(
132+
fieldpath.MakePathOrDie("spec"),
133+
),
128134
"networking/v1alpha1": fieldpath.NewSet(
129135
fieldpath.MakePathOrDie("spec"),
130136
),

pkg/registry/networking/servicecidr/strategy_test.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,6 @@ func TestServiceCIDRStrategy(t *testing.T) {
4343
t.Errorf("Expected ServiceCIDR to be cluster-scoped")
4444
}
4545

46-
resetFields := Strategy.GetResetFields()
47-
if len(resetFields) != 1 {
48-
t.Errorf("ResetFields should have 1 element, but have %d", len(resetFields))
49-
}
5046
obj := &networking.ServiceCIDR{Spec: networking.ServiceCIDRSpec{CIDRs: []string{"bad cidr"}}}
5147

5248
errors := Strategy.Validate(context.TODO(), obj)
@@ -64,11 +60,6 @@ func TestServiceCIDRStrategy(t *testing.T) {
6460
}
6561

6662
func TestServiceCIDRStatusStrategy(t *testing.T) {
67-
resetFields := StatusStrategy.GetResetFields()
68-
if len(resetFields) != 1 {
69-
t.Errorf("ResetFields should have 1 element, but have %d", len(resetFields))
70-
}
71-
7263
oldObj := &networking.ServiceCIDR{Spec: networking.ServiceCIDRSpec{}}
7364
newObj := &networking.ServiceCIDR{
7465
Spec: networking.ServiceCIDRSpec{

0 commit comments

Comments
 (0)