@@ -26,6 +26,7 @@ func Test_defaultModelBuilderTask_targetGroupAttrs(t *testing.T) {
26
26
tests := []struct {
27
27
testName string
28
28
svc * corev1.Service
29
+ port corev1.ServicePort
29
30
wantError bool
30
31
wantValue []elbv2.TargetGroupAttribute
31
32
}{
@@ -140,6 +141,45 @@ func Test_defaultModelBuilderTask_targetGroupAttrs(t *testing.T) {
140
141
},
141
142
wantError : true ,
142
143
},
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
+ },
143
183
}
144
184
for _ , tt := range tests {
145
185
t .Run (tt .testName , func (t * testing.T ) {
@@ -148,7 +188,7 @@ func Test_defaultModelBuilderTask_targetGroupAttrs(t *testing.T) {
148
188
service : tt .svc ,
149
189
annotationParser : parser ,
150
190
}
151
- tgAttrs , err := builder .buildTargetGroupAttributes (context .Background ())
191
+ tgAttrs , err := builder .buildTargetGroupAttributes (context .Background (), tt . port )
152
192
if tt .wantError {
153
193
assert .Error (t , err )
154
194
} else {
0 commit comments