mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 14:37:00 +00:00
update networking strategy and remove hardcode field on the test
This commit is contained in:
parent
c1d06c0ae4
commit
dbfdd074d0
@ -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"),
|
||||
),
|
||||
|
@ -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{
|
||||
|
Loading…
Reference in New Issue
Block a user