@@ -44,11 +44,6 @@ const (
4444	defaultInitialDelaySeconds  =  int32 (3 )
4545)
4646
47- type  PortInfo  struct  {
48- 	Port      int32 
49- 	Protocol  corev1.Protocol 
50- }
51- 
5247var  emptyDirVolumeSource  =  corev1.VolumeSource {EmptyDir : & corev1.EmptyDirVolumeSource {}}
5348
5449//nolint:gocyclo // will refactor at some point 
@@ -152,7 +147,7 @@ func (p *NginxProvisioner) buildNginxResourceObjects(
152147		openshiftObjs  =  p .buildOpenshiftObjects (objectMeta )
153148	}
154149
155- 	ports  :=  make (map [int32 ]PortInfo )
150+ 	ports  :=  make (map [int32 ]corev1. Protocol )
156151	for  _ , listener  :=  range  gateway .Spec .Listeners  {
157152		var  protocol  corev1.Protocol 
158153		switch  listener .Protocol  {
@@ -163,7 +158,7 @@ func (p *NginxProvisioner) buildNginxResourceObjects(
163158		default :
164159			protocol  =  corev1 .ProtocolTCP 
165160		}
166- 		ports [int32 (listener .Port )] =  PortInfo { Port :  int32 ( listener . Port ),  Protocol :  protocol } 
161+ 		ports [int32 (listener .Port )] =  protocol 
167162	}
168163
169164	// Create separate copies of objectMeta for service and deployment to avoid shared map references 
@@ -529,7 +524,7 @@ func (p *NginxProvisioner) buildOpenshiftObjects(objectMeta metav1.ObjectMeta) [
529524func  buildNginxService (
530525	objectMeta  metav1.ObjectMeta ,
531526	nProxyCfg  * graph.EffectiveNginxProxy ,
532- 	ports  map [int32 ]PortInfo ,
527+ 	ports  map [int32 ]corev1. Protocol ,
533528	selectorLabels  map [string ]string ,
534529	addresses  []gatewayv1.GatewaySpecAddress ,
535530) (* corev1.Service , error ) {
@@ -552,17 +547,17 @@ func buildNginxService(
552547	}
553548
554549	servicePorts  :=  make ([]corev1.ServicePort , 0 , len (ports ))
555- 	for  _ ,  portInfo  :=  range  ports  {
550+ 	for  port ,  protocol  :=  range  ports  {
556551		servicePort  :=  corev1.ServicePort {
557- 			Name :       fmt .Sprintf ("port-%d" , portInfo . Port ),
558- 			Port :       portInfo . Port ,
559- 			TargetPort : intstr .FromInt32 (portInfo . Port ),
560- 			Protocol :   portInfo . Protocol ,
552+ 			Name :       fmt .Sprintf ("port-%d" , port ),
553+ 			Port :       port ,
554+ 			TargetPort : intstr .FromInt32 (port ),
555+ 			Protocol :   protocol ,
561556		}
562557
563558		if  serviceType  !=  corev1 .ServiceTypeClusterIP  {
564559			for  _ , nodePort  :=  range  serviceCfg .NodePorts  {
565- 				if  nodePort .ListenerPort  ==  portInfo . Port  {
560+ 				if  nodePort .ListenerPort  ==  port  {
566561					servicePort .NodePort  =  nodePort .Port 
567562				}
568563			}
@@ -640,7 +635,7 @@ func (p *NginxProvisioner) buildNginxDeployment(
640635	nProxyCfg  * graph.EffectiveNginxProxy ,
641636	ngxIncludesConfigMapName  string ,
642637	ngxAgentConfigMapName  string ,
643- 	ports  map [int32 ]PortInfo ,
638+ 	ports  map [int32 ]corev1. Protocol ,
644639	selectorLabels  map [string ]string ,
645640	agentTLSSecretName  string ,
646641	dockerSecretNames  map [string ]string ,
@@ -794,7 +789,7 @@ func (p *NginxProvisioner) buildNginxPodTemplateSpec(
794789	nProxyCfg  * graph.EffectiveNginxProxy ,
795790	ngxIncludesConfigMapName  string ,
796791	ngxAgentConfigMapName  string ,
797- 	ports  map [int32 ]PortInfo ,
792+ 	ports  map [int32 ]corev1. Protocol ,
798793	agentTLSSecretName  string ,
799794	dockerSecretNames  map [string ]string ,
800795	jwtSecretName  string ,
@@ -803,11 +798,11 @@ func (p *NginxProvisioner) buildNginxPodTemplateSpec(
803798	dataplaneKeySecretName  string ,
804799) corev1.PodTemplateSpec  {
805800	containerPorts  :=  make ([]corev1.ContainerPort , 0 , len (ports ))
806- 	for  _ ,  portInfo  :=  range  ports  {
801+ 	for  port ,  protocol  :=  range  ports  {
807802		containerPort  :=  corev1.ContainerPort {
808- 			Name :          fmt .Sprintf ("port-%d" , portInfo . Port ),
809- 			ContainerPort : portInfo . Port ,
810- 			Protocol :      portInfo . Protocol ,
803+ 			Name :          fmt .Sprintf ("port-%d" , port ),
804+ 			ContainerPort : port ,
805+ 			Protocol :      protocol ,
811806		}
812807		containerPorts  =  append (containerPorts , containerPort )
813808	}
0 commit comments