@@ -26,6 +26,7 @@ func Test_defaultModelBuilderTask_targetGroupAttrs(t *testing.T) {
2626 tests := []struct {
2727 testName string
2828 svc * corev1.Service
29+ port corev1.ServicePort
2930 wantError bool
3031 wantValue []elbv2.TargetGroupAttribute
3132 }{
@@ -140,6 +141,45 @@ func Test_defaultModelBuilderTask_targetGroupAttrs(t *testing.T) {
140141 },
141142 wantError : true ,
142143 },
144+ {
145+ testName : "proxy protocol per target group port 80" ,
146+ svc : & corev1.Service {
147+ ObjectMeta : metav1.ObjectMeta {
148+ Annotations : map [string ]string {
149+ "service.beta.kubernetes.io/aws-load-balancer-proxy-protocol-per-target-group" : "80, true, 443, false" ,
150+
151+ },
152+ },
153+ },
154+ port : corev1.ServicePort {Port : 80 },
155+ wantError : false ,
156+ wantValue : []elbv2.TargetGroupAttribute {
157+ {
158+ Key : tgAttrsProxyProtocolV2Enabled ,
159+ Value : "true" ,
160+ },
161+ },
162+ },
163+ {
164+ testName : "proxy protocol per target group port 80 proxy v2 override" ,
165+ svc : & corev1.Service {
166+ ObjectMeta : metav1.ObjectMeta {
167+ Annotations : map [string ]string {
168+ "service.beta.kubernetes.io/aws-load-balancer-proxy-protocol-per-target-group" : "80, false, 443, false" ,
169+ "service.beta.kubernetes.io/aws-load-balancer-proxy-protocol" : "*" ,
170+
171+ },
172+ },
173+ },
174+ port : corev1.ServicePort {Port : 80 },
175+ wantError : false ,
176+ wantValue : []elbv2.TargetGroupAttribute {
177+ {
178+ Key : tgAttrsProxyProtocolV2Enabled ,
179+ Value : "true" ,
180+ },
181+ },
182+ },
143183 }
144184 for _ , tt := range tests {
145185 t .Run (tt .testName , func (t * testing.T ) {
@@ -148,7 +188,7 @@ func Test_defaultModelBuilderTask_targetGroupAttrs(t *testing.T) {
148188 service : tt .svc ,
149189 annotationParser : parser ,
150190 }
151- tgAttrs , err := builder .buildTargetGroupAttributes (context .Background ())
191+ tgAttrs , err := builder .buildTargetGroupAttributes (context .Background (), tt . port )
152192 if tt .wantError {
153193 assert .Error (t , err )
154194 } else {
0 commit comments