update networking strategy and remove hardcode field on the test

This commit is contained in:
Antonio Ojea 2024-06-29 10:06:00 +00:00
parent c1d06c0ae4
commit dbfdd074d0
2 changed files with 6 additions and 9 deletions

View File

@ -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"),
),

View File

@ -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{