File tree Expand file tree Collapse file tree 3 files changed +9
-7
lines changed Expand file tree Collapse file tree 3 files changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,8 @@ import (
21
21
"fmt"
22
22
"net"
23
23
24
+ "github.com/api7/gopkg/pkg/log"
25
+ "go.uber.org/zap"
24
26
corev1 "k8s.io/api/core/v1"
25
27
discoveryv1 "k8s.io/api/discovery/v1"
26
28
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -72,9 +74,7 @@ func ConvertEndpointsToEndpointSlice(ep *corev1.Endpoints) []discoveryv1.Endpoin
72
74
epPort := discoveryv1.EndpointPort {
73
75
Port : & p .Port ,
74
76
Protocol : & p .Protocol ,
75
- }
76
- if p .Name != "" {
77
- epPort .Name = & p .Name
77
+ Name : & p .Name ,
78
78
}
79
79
ports = append (ports , epPort )
80
80
}
@@ -140,6 +140,8 @@ func ConvertEndpointsToEndpointSlice(ep *corev1.Endpoints) []discoveryv1.Endpoin
140
140
}
141
141
}
142
142
143
+ log .Debugw ("Converted Endpoints to EndpointSlices" , zap .Any ("endpointSlices" , endpointSlices ))
144
+
143
145
return endpointSlices
144
146
}
145
147
Original file line number Diff line number Diff line change @@ -308,7 +308,7 @@ func TestConvertEndpointsToEndpointSlice(t *testing.T) {
308
308
},
309
309
want : []discoveryv1.EndpointSlice {
310
310
createTestEndpointSlice ("test-service-0-v4" , discoveryv1 .AddressTypeIPv4 ,
311
- []discoveryv1.EndpointPort {createPlainPort (80 )},
311
+ []discoveryv1.EndpointPort {createPlainPortWithEmptyName (80 )},
312
312
[]discoveryv1.Endpoint {createEndpointWithHostname ("192.168.1.1" , "pod-1" )}),
313
313
},
314
314
},
@@ -462,8 +462,9 @@ func createHTTPSPort(port int32) discoveryv1.EndpointPort {
462
462
}
463
463
}
464
464
465
- func createPlainPort (port int32 ) discoveryv1.EndpointPort {
465
+ func createPlainPortWithEmptyName (port int32 ) discoveryv1.EndpointPort {
466
466
return discoveryv1.EndpointPort {
467
+ Name : ptr .To ("" ),
467
468
Port : ptr .To (port ),
468
469
Protocol : ptr .To (corev1 .ProtocolTCP ),
469
470
}
Original file line number Diff line number Diff line change 83
83
selector:
84
84
app: httpbin-deployment-e2e-test
85
85
ports:
86
- - name: http
87
- port: 80
86
+ - port: 80
88
87
protocol: TCP
89
88
targetPort: 80
90
89
type: ClusterIP
You can’t perform that action at this time.
0 commit comments