Merge pull request #117625 from skitt/intstr-fromint32-cli

CLI: use new intstr functions
This commit is contained in:
Kubernetes Prow Robot
2023-05-24 14:46:49 -07:00
committed by GitHub
11 changed files with 122 additions and 121 deletions

View File

@@ -3546,8 +3546,8 @@ func TestPrintServiceList(t *testing.T) {
}
func TestPrintPodDisruptionBudget(t *testing.T) {
minAvailable := intstr.FromInt(22)
maxUnavailable := intstr.FromInt(11)
minAvailable := intstr.FromInt32(22)
maxUnavailable := intstr.FromInt32(11)
tests := []struct {
pdb policy.PodDisruptionBudget
expected []metav1.TableRow
@@ -3604,8 +3604,8 @@ func TestPrintPodDisruptionBudget(t *testing.T) {
}
func TestPrintPodDisruptionBudgetList(t *testing.T) {
minAvailable := intstr.FromInt(22)
maxUnavailable := intstr.FromInt(11)
minAvailable := intstr.FromInt32(22)
maxUnavailable := intstr.FromInt32(11)
pdbList := policy.PodDisruptionBudgetList{
Items: []policy.PodDisruptionBudget{

View File

@@ -388,24 +388,25 @@ func parsePorts(portString string) (int32, intstr.IntOrString, error) {
port, err := utilsnet.ParsePort(portStringSlice[0], true)
if err != nil {
return 0, intstr.FromInt(0), err
return 0, intstr.FromInt32(0), err
}
if len(portStringSlice) == 1 {
return int32(port), intstr.FromInt(int(port)), nil
port32 := int32(port)
return port32, intstr.FromInt32(port32), nil
}
var targetPort intstr.IntOrString
if portNum, err := strconv.Atoi(portStringSlice[1]); err != nil {
if errs := validation.IsValidPortName(portStringSlice[1]); len(errs) != 0 {
return 0, intstr.FromInt(0), fmt.Errorf(strings.Join(errs, ","))
return 0, intstr.FromInt32(0), fmt.Errorf(strings.Join(errs, ","))
}
targetPort = intstr.FromString(portStringSlice[1])
} else {
if errs := validation.IsValidPortNum(portNum); len(errs) != 0 {
return 0, intstr.FromInt(0), fmt.Errorf(strings.Join(errs, ","))
return 0, intstr.FromInt32(0), fmt.Errorf(strings.Join(errs, ","))
}
targetPort = intstr.FromInt(portNum)
targetPort = intstr.FromInt32(int32(portNum))
}
return int32(port), targetPort, nil
}

View File

@@ -482,7 +482,7 @@ func (o *ExposeServiceOptions) createService() (*corev1.Service, error) {
// should be the same as Port
for i := range service.Spec.Ports {
port := service.Spec.Ports[i].Port
service.Spec.Ports[i].TargetPort = intstr.FromInt(int(port))
service.Spec.Ports[i].TargetPort = intstr.FromInt32(port)
}
}
if len(o.ExternalIP) > 0 {

View File

@@ -68,7 +68,7 @@ func TestRunExposeService(t *testing.T) {
{
Protocol: corev1.ProtocolUDP,
Port: 14,
TargetPort: intstr.FromInt(14),
TargetPort: intstr.FromInt32(14),
},
},
Selector: map[string]string{"app": "go"},
@@ -99,7 +99,7 @@ func TestRunExposeService(t *testing.T) {
{
Protocol: corev1.ProtocolUDP,
Port: 14,
TargetPort: intstr.FromInt(14),
TargetPort: intstr.FromInt32(14),
},
},
Selector: map[string]string{"func": "stream"},
@@ -131,7 +131,7 @@ func TestRunExposeService(t *testing.T) {
{
Protocol: corev1.ProtocolTCP,
Port: 80,
TargetPort: intstr.FromInt(80),
TargetPort: intstr.FromInt32(80),
},
},
Selector: map[string]string{"run": "this"},
@@ -162,7 +162,7 @@ func TestRunExposeService(t *testing.T) {
{
Protocol: corev1.ProtocolUDP,
Port: 14,
TargetPort: intstr.FromInt(14),
TargetPort: intstr.FromInt32(14),
},
},
Selector: map[string]string{"func": "stream"},
@@ -194,7 +194,7 @@ func TestRunExposeService(t *testing.T) {
{
Protocol: corev1.ProtocolUDP,
Port: 14,
TargetPort: intstr.FromInt(14),
TargetPort: intstr.FromInt32(14),
},
},
Selector: map[string]string{"func": "stream"},
@@ -227,7 +227,7 @@ func TestRunExposeService(t *testing.T) {
{
Protocol: corev1.ProtocolUDP,
Port: 14,
TargetPort: intstr.FromInt(14),
TargetPort: intstr.FromInt32(14),
},
},
Selector: map[string]string{"func": "stream"},
@@ -259,7 +259,7 @@ func TestRunExposeService(t *testing.T) {
{
Protocol: corev1.ProtocolUDP,
Port: 14,
TargetPort: intstr.FromInt(14),
TargetPort: intstr.FromInt32(14),
},
},
Selector: map[string]string{"func": "stream"},
@@ -317,7 +317,7 @@ func TestRunExposeService(t *testing.T) {
{
Protocol: corev1.ProtocolUDP,
Port: 14,
TargetPort: intstr.FromInt(14),
TargetPort: intstr.FromInt32(14),
},
},
Selector: map[string]string{"func": "stream"},
@@ -345,7 +345,7 @@ func TestRunExposeService(t *testing.T) {
{
Protocol: corev1.ProtocolTCP,
Port: 90,
TargetPort: intstr.FromInt(90),
TargetPort: intstr.FromInt32(90),
},
},
Selector: map[string]string{"svc": "frompod"},
@@ -369,12 +369,12 @@ func TestRunExposeService(t *testing.T) {
{
Protocol: corev1.ProtocolTCP,
Port: 80,
TargetPort: intstr.FromInt(80),
TargetPort: intstr.FromInt32(80),
},
{
Protocol: corev1.ProtocolTCP,
Port: 443,
TargetPort: intstr.FromInt(443),
TargetPort: intstr.FromInt32(443),
},
},
},
@@ -388,13 +388,13 @@ func TestRunExposeService(t *testing.T) {
Name: "port-1",
Protocol: corev1.ProtocolTCP,
Port: 80,
TargetPort: intstr.FromInt(80),
TargetPort: intstr.FromInt32(80),
},
{
Name: "port-2",
Protocol: corev1.ProtocolTCP,
Port: 443,
TargetPort: intstr.FromInt(443),
TargetPort: intstr.FromInt32(443),
},
},
Selector: map[string]string{"svc": "fromfoo"},
@@ -418,22 +418,22 @@ func TestRunExposeService(t *testing.T) {
{
Protocol: corev1.ProtocolTCP,
Port: 80,
TargetPort: intstr.FromInt(80),
TargetPort: intstr.FromInt32(80),
},
{
Protocol: corev1.ProtocolUDP,
Port: 8080,
TargetPort: intstr.FromInt(8080),
TargetPort: intstr.FromInt32(8080),
},
{
Protocol: corev1.ProtocolUDP,
Port: 8081,
TargetPort: intstr.FromInt(8081),
TargetPort: intstr.FromInt32(8081),
},
{
Protocol: corev1.ProtocolSCTP,
Port: 8082,
TargetPort: intstr.FromInt(8082),
TargetPort: intstr.FromInt32(8082),
},
},
},
@@ -447,25 +447,25 @@ func TestRunExposeService(t *testing.T) {
Name: "port-1",
Protocol: corev1.ProtocolTCP,
Port: 80,
TargetPort: intstr.FromInt(80),
TargetPort: intstr.FromInt32(80),
},
{
Name: "port-2",
Protocol: corev1.ProtocolUDP,
Port: 8080,
TargetPort: intstr.FromInt(8080),
TargetPort: intstr.FromInt32(8080),
},
{
Name: "port-3",
Protocol: corev1.ProtocolUDP,
Port: 8081,
TargetPort: intstr.FromInt(8081),
TargetPort: intstr.FromInt32(8081),
},
{
Name: "port-4",
Protocol: corev1.ProtocolSCTP,
Port: 8082,
TargetPort: intstr.FromInt(8082),
TargetPort: intstr.FromInt32(8082),
},
},
Selector: map[string]string{"svc": "fromfoo"},
@@ -496,7 +496,7 @@ func TestRunExposeService(t *testing.T) {
{
Protocol: corev1.ProtocolSCTP,
Port: 14,
TargetPort: intstr.FromInt(14),
TargetPort: intstr.FromInt32(14),
},
},
Selector: map[string]string{"app": "go"},
@@ -527,7 +527,7 @@ func TestRunExposeService(t *testing.T) {
{
Protocol: corev1.ProtocolSCTP,
Port: 14,
TargetPort: intstr.FromInt(14),
TargetPort: intstr.FromInt32(14),
},
},
Selector: map[string]string{"func": "stream"},
@@ -558,7 +558,7 @@ func TestRunExposeService(t *testing.T) {
{
Protocol: corev1.ProtocolSCTP,
Port: 14,
TargetPort: intstr.FromInt(14),
TargetPort: intstr.FromInt32(14),
},
},
Selector: map[string]string{"func": "stream"},
@@ -590,7 +590,7 @@ func TestRunExposeService(t *testing.T) {
{
Protocol: corev1.ProtocolSCTP,
Port: 14,
TargetPort: intstr.FromInt(14),
TargetPort: intstr.FromInt32(14),
},
},
Selector: map[string]string{"func": "stream"},
@@ -622,7 +622,7 @@ func TestRunExposeService(t *testing.T) {
{
Protocol: corev1.ProtocolUDP,
Port: 14,
TargetPort: intstr.FromInt(14),
TargetPort: intstr.FromInt32(14),
},
},
Selector: map[string]string{"func": "stream"},
@@ -821,7 +821,7 @@ status:
{
Protocol: corev1.ProtocolUDP,
Port: 14,
TargetPort: intstr.FromInt(14),
TargetPort: intstr.FromInt32(14),
},
},
Selector: map[string]string{"app": "go"},
@@ -897,7 +897,7 @@ func TestGenerateService(t *testing.T) {
{
Port: 80,
Protocol: "TCP",
TargetPort: intstr.FromInt(1234),
TargetPort: intstr.FromInt32(1234),
},
},
},
@@ -952,7 +952,7 @@ func TestGenerateService(t *testing.T) {
{
Port: 80,
Protocol: "TCP",
TargetPort: intstr.FromInt(1234),
TargetPort: intstr.FromInt32(1234),
},
},
},
@@ -1087,7 +1087,7 @@ func TestGenerateService(t *testing.T) {
{
Port: 80,
Protocol: "TCP",
TargetPort: intstr.FromInt(1234),
TargetPort: intstr.FromInt32(1234),
},
},
},
@@ -1113,7 +1113,7 @@ func TestGenerateService(t *testing.T) {
{
Port: 80,
Protocol: "TCP",
TargetPort: intstr.FromInt(1234),
TargetPort: intstr.FromInt32(1234),
},
},
SessionAffinity: corev1.ServiceAffinityClientIP,
@@ -1141,7 +1141,7 @@ func TestGenerateService(t *testing.T) {
Port: 80,
Protocol: "TCP",
TargetPort: intstr.FromInt(1234),
TargetPort: intstr.FromInt32(1234),
},
},
ClusterIP: "10.10.10.10",
@@ -1169,7 +1169,7 @@ func TestGenerateService(t *testing.T) {
Port: 80,
Protocol: "TCP",
TargetPort: intstr.FromInt(1234),
TargetPort: intstr.FromInt32(1234),
},
},
ClusterIP: corev1.ClusterIPNone,
@@ -1226,13 +1226,13 @@ func TestGenerateService(t *testing.T) {
Name: "port-1",
Port: 80,
Protocol: corev1.ProtocolUDP,
TargetPort: intstr.FromInt(1234),
TargetPort: intstr.FromInt32(1234),
},
{
Name: "port-2",
Port: 443,
Protocol: corev1.ProtocolUDP,
TargetPort: intstr.FromInt(1234),
TargetPort: intstr.FromInt32(1234),
},
},
},
@@ -1256,13 +1256,13 @@ func TestGenerateService(t *testing.T) {
Name: "port-1",
Port: 80,
Protocol: corev1.ProtocolTCP,
TargetPort: intstr.FromInt(80),
TargetPort: intstr.FromInt32(80),
},
{
Name: "port-2",
Port: 443,
Protocol: corev1.ProtocolTCP,
TargetPort: intstr.FromInt(443),
TargetPort: intstr.FromInt32(443),
},
},
},
@@ -1286,13 +1286,13 @@ func TestGenerateService(t *testing.T) {
Name: "port-1",
Port: 80,
Protocol: corev1.ProtocolTCP,
TargetPort: intstr.FromInt(80),
TargetPort: intstr.FromInt32(80),
},
{
Name: "port-2",
Port: 8080,
Protocol: corev1.ProtocolUDP,
TargetPort: intstr.FromInt(8080),
TargetPort: intstr.FromInt32(8080),
},
},
},
@@ -1316,19 +1316,19 @@ func TestGenerateService(t *testing.T) {
Name: "port-1",
Port: 80,
Protocol: corev1.ProtocolTCP,
TargetPort: intstr.FromInt(80),
TargetPort: intstr.FromInt32(80),
},
{
Name: "port-2",
Port: 8080,
Protocol: corev1.ProtocolUDP,
TargetPort: intstr.FromInt(8080),
TargetPort: intstr.FromInt32(8080),
},
{
Name: "port-3",
Port: 8081,
Protocol: corev1.ProtocolTCP,
TargetPort: intstr.FromInt(8081),
TargetPort: intstr.FromInt32(8081),
},
},
},
@@ -1390,7 +1390,7 @@ func TestGenerateService(t *testing.T) {
Port: 80,
Protocol: "SCTP",
TargetPort: intstr.FromInt(1234),
TargetPort: intstr.FromInt32(1234),
},
},
},
@@ -1421,7 +1421,7 @@ func TestGenerateService(t *testing.T) {
Port: 80,
Protocol: "SCTP",
TargetPort: intstr.FromInt(1234),
TargetPort: intstr.FromInt32(1234),
},
},
},
@@ -1447,7 +1447,7 @@ func TestGenerateService(t *testing.T) {
Port: 80,
Protocol: "SCTP",
TargetPort: intstr.FromInt(1234),
TargetPort: intstr.FromInt32(1234),
},
},
},
@@ -1473,7 +1473,7 @@ func TestGenerateService(t *testing.T) {
{
Port: 80,
Protocol: "SCTP",
TargetPort: intstr.FromInt(1234),
TargetPort: intstr.FromInt32(1234),
},
},
SessionAffinity: corev1.ServiceAffinityClientIP,
@@ -1500,7 +1500,7 @@ func TestGenerateService(t *testing.T) {
{
Port: 80,
Protocol: "SCTP",
TargetPort: intstr.FromInt(1234),
TargetPort: intstr.FromInt32(1234),
},
},
ClusterIP: "10.10.10.10",
@@ -1528,7 +1528,7 @@ func TestGenerateService(t *testing.T) {
Port: 80,
Protocol: "SCTP",
TargetPort: intstr.FromInt(1234),
TargetPort: intstr.FromInt32(1234),
},
},
ClusterIP: corev1.ClusterIPNone,
@@ -1584,13 +1584,13 @@ func TestGenerateService(t *testing.T) {
Name: "port-1",
Port: 80,
Protocol: corev1.ProtocolSCTP,
TargetPort: intstr.FromInt(80),
TargetPort: intstr.FromInt32(80),
},
{
Name: "port-2",
Port: 443,
Protocol: corev1.ProtocolSCTP,
TargetPort: intstr.FromInt(443),
TargetPort: intstr.FromInt32(443),
},
},
},
@@ -1614,13 +1614,13 @@ func TestGenerateService(t *testing.T) {
Name: "port-1",
Port: 80,
Protocol: corev1.ProtocolTCP,
TargetPort: intstr.FromInt(80),
TargetPort: intstr.FromInt32(80),
},
{
Name: "port-2",
Port: 8080,
Protocol: corev1.ProtocolSCTP,
TargetPort: intstr.FromInt(8080),
TargetPort: intstr.FromInt32(8080),
},
},
},
@@ -1644,25 +1644,25 @@ func TestGenerateService(t *testing.T) {
Name: "port-1",
Port: 80,
Protocol: corev1.ProtocolTCP,
TargetPort: intstr.FromInt(80),
TargetPort: intstr.FromInt32(80),
},
{
Name: "port-2",
Port: 8080,
Protocol: corev1.ProtocolUDP,
TargetPort: intstr.FromInt(8080),
TargetPort: intstr.FromInt32(8080),
},
{
Name: "port-3",
Port: 8081,
Protocol: corev1.ProtocolTCP,
TargetPort: intstr.FromInt(8081),
TargetPort: intstr.FromInt32(8081),
},
{
Name: "port-4",
Port: 8082,
Protocol: corev1.ProtocolSCTP,
TargetPort: intstr.FromInt(8082),
TargetPort: intstr.FromInt32(8082),
},
},
},

View File

@@ -158,7 +158,7 @@ func TestTranslateServicePortToTargetPort(t *testing.T) {
Ports: []corev1.ServicePort{
{
Port: 80,
TargetPort: intstr.FromInt(8080),
TargetPort: intstr.FromInt32(8080),
},
},
},
@@ -187,7 +187,7 @@ func TestTranslateServicePortToTargetPort(t *testing.T) {
Ports: []corev1.ServicePort{
{
Port: 80,
TargetPort: intstr.FromInt(8080),
TargetPort: intstr.FromInt32(8080),
},
},
},
@@ -216,7 +216,7 @@ func TestTranslateServicePortToTargetPort(t *testing.T) {
Ports: []corev1.ServicePort{
{
Port: 8080,
TargetPort: intstr.FromInt(8080),
TargetPort: intstr.FromInt32(8080),
},
},
},
@@ -246,7 +246,7 @@ func TestTranslateServicePortToTargetPort(t *testing.T) {
Ports: []corev1.ServicePort{
{
Port: 80,
TargetPort: intstr.FromInt(8080),
TargetPort: intstr.FromInt32(8080),
},
},
},
@@ -276,7 +276,7 @@ func TestTranslateServicePortToTargetPort(t *testing.T) {
Ports: []corev1.ServicePort{
{
Port: 80,
TargetPort: intstr.FromInt(8080),
TargetPort: intstr.FromInt32(8080),
},
},
},
@@ -378,12 +378,12 @@ func TestTranslateServicePortToTargetPort(t *testing.T) {
{
Port: 80,
Name: "http",
TargetPort: intstr.FromInt(8080),
TargetPort: intstr.FromInt32(8080),
},
{
Port: 443,
Name: "https",
TargetPort: intstr.FromInt(8443),
TargetPort: intstr.FromInt32(8443),
},
},
},
@@ -414,12 +414,12 @@ func TestTranslateServicePortToTargetPort(t *testing.T) {
{
Port: 80,
Name: "http",
TargetPort: intstr.FromInt(8080),
TargetPort: intstr.FromInt32(8080),
},
{
Port: 443,
Name: "https",
TargetPort: intstr.FromInt(8443),
TargetPort: intstr.FromInt32(8443),
},
},
},

View File

@@ -262,7 +262,7 @@ func TestGenerateService(t *testing.T) {
{
Port: 80,
Protocol: "TCP",
TargetPort: intstr.FromInt(80),
TargetPort: intstr.FromInt32(80),
},
},
Selector: map[string]string{
@@ -295,7 +295,7 @@ func TestGenerateService(t *testing.T) {
{
Port: 80,
Protocol: "TCP",
TargetPort: intstr.FromInt(80),
TargetPort: intstr.FromInt32(80),
},
},
Selector: map[string]string{

View File

@@ -667,7 +667,7 @@ func TestDescribeService(t *testing.T) {
Name: "port-tcp",
Port: 8080,
Protocol: corev1.ProtocolTCP,
TargetPort: intstr.FromInt(9527),
TargetPort: intstr.FromInt32(9527),
NodePort: 31111,
}},
Selector: map[string]string{"blah": "heh"},
@@ -2772,7 +2772,7 @@ func TestDescribeIngress(t *testing.T) {
ingresClassName := "test"
backendV1beta1 := networkingv1beta1.IngressBackend{
ServiceName: "default-backend",
ServicePort: intstr.FromInt(80),
ServicePort: intstr.FromInt32(80),
}
v1beta1 := fake.NewSimpleClientset(&networkingv1beta1.Ingress{
ObjectMeta: metav1.ObjectMeta{
@@ -3332,7 +3332,7 @@ func TestDescribeCSINode(t *testing.T) {
}
func TestDescribePodDisruptionBudgetV1beta1(t *testing.T) {
minAvailable := intstr.FromInt(22)
minAvailable := intstr.FromInt32(22)
f := fake.NewSimpleClientset(&policyv1beta1.PodDisruptionBudget{
ObjectMeta: metav1.ObjectMeta{
Namespace: "ns1",
@@ -3360,7 +3360,7 @@ func TestDescribePodDisruptionBudgetV1beta1(t *testing.T) {
}
func TestDescribePodDisruptionBudgetV1(t *testing.T) {
minAvailable := intstr.FromInt(22)
minAvailable := intstr.FromInt32(22)
f := fake.NewSimpleClientset(&policyv1.PodDisruptionBudget{
ObjectMeta: metav1.ObjectMeta{
Namespace: "ns1",
@@ -4851,8 +4851,8 @@ Spec:
Policy Types: Ingress, Egress
`
port80 := intstr.FromInt(80)
port82 := intstr.FromInt(82)
port80 := intstr.FromInt32(80)
port82 := intstr.FromInt32(82)
protoTCP := corev1.ProtocolTCP
versionedFake := fake.NewSimpleClientset(&networkingv1.NetworkPolicy{
@@ -5036,8 +5036,8 @@ Spec:
Policy Types: Ingress
`
port80 := intstr.FromInt(80)
port82 := intstr.FromInt(82)
port80 := intstr.FromInt32(80)
port82 := intstr.FromInt32(82)
protoTCP := corev1.ProtocolTCP
versionedFake := fake.NewSimpleClientset(&networkingv1.NetworkPolicy{
@@ -5164,8 +5164,8 @@ Spec:
Policy Types: Ingress, Egress
`
port80 := intstr.FromInt(80)
port82 := intstr.FromInt(82)
port80 := intstr.FromInt32(80)
port82 := intstr.FromInt32(82)
protoTCP := corev1.ProtocolTCP
versionedFake := fake.NewSimpleClientset(&networkingv1.NetworkPolicy{

View File

@@ -207,7 +207,7 @@ func generateService(genericParams map[string]interface{}) (runtime.Object, erro
// should be the same as Port
for i := range service.Spec.Ports {
port := service.Spec.Ports[i].Port
service.Spec.Ports[i].TargetPort = intstr.FromInt(int(port))
service.Spec.Ports[i].TargetPort = intstr.FromInt32(port)
}
}
if len(params["external-ip"]) > 0 {

View File

@@ -56,7 +56,7 @@ func TestGenerateService(t *testing.T) {
{
Port: 80,
Protocol: "TCP",
TargetPort: intstr.FromInt(1234),
TargetPort: intstr.FromInt32(1234),
},
},
},
@@ -119,7 +119,7 @@ func TestGenerateService(t *testing.T) {
{
Port: 80,
Protocol: "TCP",
TargetPort: intstr.FromInt(1234),
TargetPort: intstr.FromInt32(1234),
},
},
},
@@ -276,7 +276,7 @@ func TestGenerateService(t *testing.T) {
Name: "default",
Port: 80,
Protocol: "TCP",
TargetPort: intstr.FromInt(1234),
TargetPort: intstr.FromInt32(1234),
},
},
},
@@ -307,7 +307,7 @@ func TestGenerateService(t *testing.T) {
Name: "default",
Port: 80,
Protocol: "TCP",
TargetPort: intstr.FromInt(1234),
TargetPort: intstr.FromInt32(1234),
},
},
SessionAffinity: v1.ServiceAffinityClientIP,
@@ -338,7 +338,7 @@ func TestGenerateService(t *testing.T) {
{
Port: 80,
Protocol: "TCP",
TargetPort: intstr.FromInt(1234),
TargetPort: intstr.FromInt32(1234),
},
},
ClusterIP: "10.10.10.10",
@@ -369,7 +369,7 @@ func TestGenerateService(t *testing.T) {
{
Port: 80,
Protocol: "TCP",
TargetPort: intstr.FromInt(1234),
TargetPort: intstr.FromInt32(1234),
},
},
ClusterIP: v1.ClusterIPNone,
@@ -434,13 +434,13 @@ func TestGenerateService(t *testing.T) {
Name: "port-1",
Port: 80,
Protocol: v1.ProtocolUDP,
TargetPort: intstr.FromInt(1234),
TargetPort: intstr.FromInt32(1234),
},
{
Name: "port-2",
Port: 443,
Protocol: v1.ProtocolUDP,
TargetPort: intstr.FromInt(1234),
TargetPort: intstr.FromInt32(1234),
},
},
},
@@ -468,13 +468,13 @@ func TestGenerateService(t *testing.T) {
Name: "port-1",
Port: 80,
Protocol: v1.ProtocolTCP,
TargetPort: intstr.FromInt(80),
TargetPort: intstr.FromInt32(80),
},
{
Name: "port-2",
Port: 443,
Protocol: v1.ProtocolTCP,
TargetPort: intstr.FromInt(443),
TargetPort: intstr.FromInt32(443),
},
},
},
@@ -502,13 +502,13 @@ func TestGenerateService(t *testing.T) {
Name: "port-1",
Port: 80,
Protocol: v1.ProtocolTCP,
TargetPort: intstr.FromInt(80),
TargetPort: intstr.FromInt32(80),
},
{
Name: "port-2",
Port: 8080,
Protocol: v1.ProtocolUDP,
TargetPort: intstr.FromInt(8080),
TargetPort: intstr.FromInt32(8080),
},
},
},
@@ -536,19 +536,19 @@ func TestGenerateService(t *testing.T) {
Name: "port-1",
Port: 80,
Protocol: v1.ProtocolTCP,
TargetPort: intstr.FromInt(80),
TargetPort: intstr.FromInt32(80),
},
{
Name: "port-2",
Port: 8080,
Protocol: v1.ProtocolUDP,
TargetPort: intstr.FromInt(8080),
TargetPort: intstr.FromInt32(8080),
},
{
Name: "port-3",
Port: 8081,
Protocol: v1.ProtocolTCP,
TargetPort: intstr.FromInt(8081),
TargetPort: intstr.FromInt32(8081),
},
},
},
@@ -621,7 +621,7 @@ func TestGenerateService(t *testing.T) {
{
Port: 80,
Protocol: "SCTP",
TargetPort: intstr.FromInt(1234),
TargetPort: intstr.FromInt32(1234),
},
},
},
@@ -654,7 +654,7 @@ func TestGenerateService(t *testing.T) {
{
Port: 80,
Protocol: "SCTP",
TargetPort: intstr.FromInt(1234),
TargetPort: intstr.FromInt32(1234),
},
},
},
@@ -683,7 +683,7 @@ func TestGenerateService(t *testing.T) {
Name: "default",
Port: 80,
Protocol: "SCTP",
TargetPort: intstr.FromInt(1234),
TargetPort: intstr.FromInt32(1234),
},
},
},
@@ -713,7 +713,7 @@ func TestGenerateService(t *testing.T) {
Name: "default",
Port: 80,
Protocol: "SCTP",
TargetPort: intstr.FromInt(1234),
TargetPort: intstr.FromInt32(1234),
},
},
SessionAffinity: v1.ServiceAffinityClientIP,
@@ -743,7 +743,7 @@ func TestGenerateService(t *testing.T) {
{
Port: 80,
Protocol: "SCTP",
TargetPort: intstr.FromInt(1234),
TargetPort: intstr.FromInt32(1234),
},
},
ClusterIP: "10.10.10.10",
@@ -773,7 +773,7 @@ func TestGenerateService(t *testing.T) {
{
Port: 80,
Protocol: "SCTP",
TargetPort: intstr.FromInt(1234),
TargetPort: intstr.FromInt32(1234),
},
},
ClusterIP: v1.ClusterIPNone,
@@ -835,13 +835,13 @@ func TestGenerateService(t *testing.T) {
Name: "port-1",
Port: 80,
Protocol: v1.ProtocolSCTP,
TargetPort: intstr.FromInt(80),
TargetPort: intstr.FromInt32(80),
},
{
Name: "port-2",
Port: 443,
Protocol: v1.ProtocolSCTP,
TargetPort: intstr.FromInt(443),
TargetPort: intstr.FromInt32(443),
},
},
},
@@ -868,13 +868,13 @@ func TestGenerateService(t *testing.T) {
Name: "port-1",
Port: 80,
Protocol: v1.ProtocolTCP,
TargetPort: intstr.FromInt(80),
TargetPort: intstr.FromInt32(80),
},
{
Name: "port-2",
Port: 8080,
Protocol: v1.ProtocolSCTP,
TargetPort: intstr.FromInt(8080),
TargetPort: intstr.FromInt32(8080),
},
},
},
@@ -901,25 +901,25 @@ func TestGenerateService(t *testing.T) {
Name: "port-1",
Port: 80,
Protocol: v1.ProtocolTCP,
TargetPort: intstr.FromInt(80),
TargetPort: intstr.FromInt32(80),
},
{
Name: "port-2",
Port: 8080,
Protocol: v1.ProtocolUDP,
TargetPort: intstr.FromInt(8080),
TargetPort: intstr.FromInt32(8080),
},
{
Name: "port-3",
Port: 8081,
Protocol: v1.ProtocolTCP,
TargetPort: intstr.FromInt(8081),
TargetPort: intstr.FromInt32(8081),
},
{
Name: "port-4",
Port: 8082,
Protocol: v1.ProtocolSCTP,
TargetPort: intstr.FromInt(8082),
TargetPort: intstr.FromInt32(8082),
},
},
},

View File

@@ -236,11 +236,11 @@ func findOldReplicaSets(deployment *appsv1.Deployment, rsList []*appsv1.ReplicaS
// 2 desired, max unavailable 0%, surge 1% - should scale new(+1), then old(-1), then new(+1), then old(-1)
// 1 desired, max unavailable 0%, surge 1% - should scale new(+1), then old(-1)
func ResolveFenceposts(maxSurge, maxUnavailable *intstrutil.IntOrString, desired int32) (int32, int32, error) {
surge, err := intstrutil.GetScaledValueFromIntOrPercent(intstrutil.ValueOrDefault(maxSurge, intstrutil.FromInt(0)), int(desired), true)
surge, err := intstrutil.GetScaledValueFromIntOrPercent(intstrutil.ValueOrDefault(maxSurge, intstrutil.FromInt32(0)), int(desired), true)
if err != nil {
return 0, 0, err
}
unavailable, err := intstrutil.GetScaledValueFromIntOrPercent(intstrutil.ValueOrDefault(maxUnavailable, intstrutil.FromInt(0)), int(desired), false)
unavailable, err := intstrutil.GetScaledValueFromIntOrPercent(intstrutil.ValueOrDefault(maxUnavailable, intstrutil.FromInt32(0)), int(desired), false)
if err != nil {
return 0, 0, err
}

View File

@@ -39,7 +39,7 @@ func TestLookupContainerPortNumberByServicePort(t *testing.T) {
Ports: []v1.ServicePort{
{
Port: 80,
TargetPort: intstr.FromInt(8080),
TargetPort: intstr.FromInt32(8080),
},
},
},
@@ -69,7 +69,7 @@ func TestLookupContainerPortNumberByServicePort(t *testing.T) {
Ports: []v1.ServicePort{
{
Port: 80,
TargetPort: intstr.FromInt(8080),
TargetPort: intstr.FromInt32(8080),
},
},
},