mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-07 11:13:48 +00:00
Chore: add ipfamilies tweak functions
This commit is contained in:
parent
c471f03ea3
commit
f7ce6f834a
@ -123,6 +123,12 @@ func tweakAddAppProtocol(appProtocol string) serviceTweak {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func tweakAddIPFamilies(families ...v1.IPFamily) serviceTweak {
|
||||||
|
return func(s *v1.Service) {
|
||||||
|
s.Spec.IPFamilies = families
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Wrap newService so that you don't have to call default arguments again and again.
|
// Wrap newService so that you don't have to call default arguments again and again.
|
||||||
func defaultExternalService() *v1.Service {
|
func defaultExternalService() *v1.Service {
|
||||||
return newService("external-balancer", v1.ServiceTypeLoadBalancer)
|
return newService("external-balancer", v1.ServiceTypeLoadBalancer)
|
||||||
@ -1366,23 +1372,7 @@ func TestNeedsUpdate(t *testing.T) {
|
|||||||
}, {
|
}, {
|
||||||
testName: "If service IPFamilies from single stack to dual stack",
|
testName: "If service IPFamilies from single stack to dual stack",
|
||||||
updateFn: func() {
|
updateFn: func() {
|
||||||
protocol := "http"
|
oldSvc = newService("tcp-service", v1.ServiceTypeLoadBalancer, tweakAddPorts(v1.ProtocolTCP, 22), tweakAddAppProtocol("http"), tweakAddIPFamilies(v1.IPv4Protocol))
|
||||||
oldSvc = &v1.Service{
|
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
|
||||||
Name: "tcp-service",
|
|
||||||
Namespace: "default",
|
|
||||||
},
|
|
||||||
Spec: v1.ServiceSpec{
|
|
||||||
Ports: []v1.ServicePort{{
|
|
||||||
Port: 80,
|
|
||||||
Protocol: v1.ProtocolTCP,
|
|
||||||
TargetPort: intstr.Parse("22"),
|
|
||||||
AppProtocol: &protocol,
|
|
||||||
}},
|
|
||||||
IPFamilies: []v1.IPFamily{v1.IPv4Protocol},
|
|
||||||
Type: v1.ServiceTypeLoadBalancer,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
newSvc = oldSvc.DeepCopy()
|
newSvc = oldSvc.DeepCopy()
|
||||||
newSvc.Spec.IPFamilies = []v1.IPFamily{v1.IPv4Protocol, v1.IPv6Protocol}
|
newSvc.Spec.IPFamilies = []v1.IPFamily{v1.IPv4Protocol, v1.IPv6Protocol}
|
||||||
},
|
},
|
||||||
@ -1390,23 +1380,7 @@ func TestNeedsUpdate(t *testing.T) {
|
|||||||
}, {
|
}, {
|
||||||
testName: "If service IPFamilies from dual stack to single stack",
|
testName: "If service IPFamilies from dual stack to single stack",
|
||||||
updateFn: func() {
|
updateFn: func() {
|
||||||
protocol := "http"
|
oldSvc = newService("tcp-service", v1.ServiceTypeLoadBalancer, tweakAddPorts(v1.ProtocolTCP, 22), tweakAddAppProtocol("http"), tweakAddIPFamilies(v1.IPv4Protocol, v1.IPv6Protocol))
|
||||||
oldSvc = &v1.Service{
|
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
|
||||||
Name: "tcp-service",
|
|
||||||
Namespace: "default",
|
|
||||||
},
|
|
||||||
Spec: v1.ServiceSpec{
|
|
||||||
Ports: []v1.ServicePort{{
|
|
||||||
Port: 80,
|
|
||||||
Protocol: v1.ProtocolTCP,
|
|
||||||
TargetPort: intstr.Parse("22"),
|
|
||||||
AppProtocol: &protocol,
|
|
||||||
}},
|
|
||||||
IPFamilies: []v1.IPFamily{v1.IPv4Protocol, v1.IPv6Protocol},
|
|
||||||
Type: v1.ServiceTypeLoadBalancer,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
newSvc = oldSvc.DeepCopy()
|
newSvc = oldSvc.DeepCopy()
|
||||||
newSvc.Spec.IPFamilies = []v1.IPFamily{v1.IPv4Protocol}
|
newSvc.Spec.IPFamilies = []v1.IPFamily{v1.IPv4Protocol}
|
||||||
},
|
},
|
||||||
@ -1414,23 +1388,7 @@ func TestNeedsUpdate(t *testing.T) {
|
|||||||
}, {
|
}, {
|
||||||
testName: "If service IPFamilies not change",
|
testName: "If service IPFamilies not change",
|
||||||
updateFn: func() {
|
updateFn: func() {
|
||||||
protocol := "http"
|
oldSvc = newService("tcp-service", v1.ServiceTypeLoadBalancer, tweakAddPorts(v1.ProtocolTCP, 22), tweakAddAppProtocol("http"), tweakAddIPFamilies(v1.IPv4Protocol))
|
||||||
oldSvc = &v1.Service{
|
|
||||||
ObjectMeta: metav1.ObjectMeta{
|
|
||||||
Name: "tcp-service",
|
|
||||||
Namespace: "default",
|
|
||||||
},
|
|
||||||
Spec: v1.ServiceSpec{
|
|
||||||
Ports: []v1.ServicePort{{
|
|
||||||
Port: 80,
|
|
||||||
Protocol: v1.ProtocolTCP,
|
|
||||||
TargetPort: intstr.Parse("22"),
|
|
||||||
AppProtocol: &protocol,
|
|
||||||
}},
|
|
||||||
IPFamilies: []v1.IPFamily{v1.IPv4Protocol},
|
|
||||||
Type: v1.ServiceTypeLoadBalancer,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
newSvc = oldSvc.DeepCopy()
|
newSvc = oldSvc.DeepCopy()
|
||||||
},
|
},
|
||||||
expectedNeedsUpdate: false,
|
expectedNeedsUpdate: false,
|
||||||
|
Loading…
Reference in New Issue
Block a user