mirror of https://github.com/k3s-io/k3s
Duplicate service port name can't be validated
Duplicate service port name can't be validated Duplicate service port name can't be validated Duplicate service port name can't be validatedpull/6/head
parent
be15e84e83
commit
4bb594b34d
|
@ -1028,6 +1028,8 @@ func validateServicePort(sp *api.ServicePort, requireName bool, allNames *util.S
|
|||
allErrs = append(allErrs, errs.NewFieldInvalid("name", sp.Name, dns1123LabelErrorMsg))
|
||||
} else if allNames.Has(sp.Name) {
|
||||
allErrs = append(allErrs, errs.NewFieldDuplicate("name", sp.Name))
|
||||
} else {
|
||||
allNames.Insert(sp.Name)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1682,7 +1682,7 @@ func TestValidateService(t *testing.T) {
|
|||
name: "dup port name",
|
||||
tweakSvc: func(s *api.Service) {
|
||||
s.Spec.Ports[0].Name = "p"
|
||||
s.Spec.Ports = append(s.Spec.Ports, api.ServicePort{Name: "p", Port: 12345})
|
||||
s.Spec.Ports = append(s.Spec.Ports, api.ServicePort{Name: "p", Port: 12345, Protocol: "TCP"})
|
||||
},
|
||||
numErrs: 1,
|
||||
},
|
||||
|
@ -1698,7 +1698,7 @@ func TestValidateService(t *testing.T) {
|
|||
name: "invalid load balancer protocol 2",
|
||||
tweakSvc: func(s *api.Service) {
|
||||
s.Spec.CreateExternalLoadBalancer = true
|
||||
s.Spec.Ports = append(s.Spec.Ports, api.ServicePort{Name: "p", Port: 12345, Protocol: "UDP"})
|
||||
s.Spec.Ports = append(s.Spec.Ports, api.ServicePort{Name: "q", Port: 12345, Protocol: "UDP"})
|
||||
},
|
||||
numErrs: 1,
|
||||
},
|
||||
|
@ -1750,7 +1750,7 @@ func TestValidateService(t *testing.T) {
|
|||
name: "valid external load balancer 2 ports",
|
||||
tweakSvc: func(s *api.Service) {
|
||||
s.Spec.CreateExternalLoadBalancer = true
|
||||
s.Spec.Ports = append(s.Spec.Ports, api.ServicePort{Name: "p", Port: 12345, Protocol: "TCP"})
|
||||
s.Spec.Ports = append(s.Spec.Ports, api.ServicePort{Name: "q", Port: 12345, Protocol: "TCP"})
|
||||
},
|
||||
numErrs: 0,
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue