mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-21 01:50:55 +00:00
Graduating AppProtocol to GA
This commit is contained in:
@@ -639,12 +639,10 @@ func shouldPodBeInEndpoints(pod *v1.Pod) bool {
|
||||
|
||||
func endpointPortFromServicePort(servicePort *v1.ServicePort, portNum int) *v1.EndpointPort {
|
||||
epp := &v1.EndpointPort{
|
||||
Name: servicePort.Name,
|
||||
Port: int32(portNum),
|
||||
Protocol: servicePort.Protocol,
|
||||
}
|
||||
if utilfeature.DefaultFeatureGate.Enabled(features.ServiceAppProtocol) {
|
||||
epp.AppProtocol = servicePort.AppProtocol
|
||||
Name: servicePort.Name,
|
||||
Port: int32(portNum),
|
||||
Protocol: servicePort.Protocol,
|
||||
AppProtocol: servicePort.AppProtocol,
|
||||
}
|
||||
return epp
|
||||
}
|
||||
|
@@ -1984,27 +1984,14 @@ func TestSyncEndpointsServiceNotFound(t *testing.T) {
|
||||
func TestEndpointPortFromServicePort(t *testing.T) {
|
||||
http := utilpointer.StringPtr("http")
|
||||
testCases := map[string]struct {
|
||||
featureGateEnabled bool
|
||||
serviceAppProtocol *string
|
||||
expectedEndpointsAppProtocol *string
|
||||
}{
|
||||
"feature gate disabled, empty app protocol": {
|
||||
featureGateEnabled: false,
|
||||
"empty app protocol": {
|
||||
serviceAppProtocol: nil,
|
||||
expectedEndpointsAppProtocol: nil,
|
||||
},
|
||||
"feature gate disabled, http app protocol": {
|
||||
featureGateEnabled: false,
|
||||
serviceAppProtocol: http,
|
||||
expectedEndpointsAppProtocol: nil,
|
||||
},
|
||||
"feature gate enabled, empty app protocol": {
|
||||
featureGateEnabled: true,
|
||||
serviceAppProtocol: nil,
|
||||
expectedEndpointsAppProtocol: nil,
|
||||
},
|
||||
"feature gate enabled, http app protocol": {
|
||||
featureGateEnabled: true,
|
||||
"http app protocol": {
|
||||
serviceAppProtocol: http,
|
||||
expectedEndpointsAppProtocol: http,
|
||||
},
|
||||
@@ -2012,8 +1999,6 @@ func TestEndpointPortFromServicePort(t *testing.T) {
|
||||
|
||||
for name, tc := range testCases {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.ServiceAppProtocol, tc.featureGateEnabled)()
|
||||
|
||||
epp := endpointPortFromServicePort(&v1.ServicePort{Name: "test", AppProtocol: tc.serviceAppProtocol}, 80)
|
||||
|
||||
if epp.AppProtocol != tc.expectedEndpointsAppProtocol {
|
||||
|
Reference in New Issue
Block a user