@@ -677,7 +677,16 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
677
677
config : Config {},
678
678
namespaces : namespaces ("default" ),
679
679
gateways : []* v1beta1.Gateway {{
680
- ObjectMeta : objectMeta ("default" , "test" ),
680
+ TypeMeta : metav1.TypeMeta {
681
+ Kind : "Gateway" ,
682
+ },
683
+ ObjectMeta : metav1.ObjectMeta {
684
+ Name : "test" ,
685
+ Namespace : "default" ,
686
+ Annotations : map [string ]string {
687
+ hostnameAnnotationKey : "annotation.gateway.internal" ,
688
+ },
689
+ },
681
690
Spec : v1.GatewaySpec {
682
691
Listeners : []v1.Listener {{Protocol : v1 .HTTPProtocolType }},
683
692
},
@@ -712,6 +721,10 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
712
721
},
713
722
},
714
723
endpoints : []* endpoint.Endpoint {
724
+ newTestEndpoint ("annotation.gateway.internal" , "A" , "1.2.3.4" ).
725
+ WithLabel (endpoint .ResourceLabelKey , "gateway/default/test" ),
726
+ newTestEndpoint ("annotation.gateway.internal" , "A" , "1.2.3.4" ).
727
+ WithLabel (endpoint .ResourceLabelKey , "gateway/default/test" ),
715
728
newTestEndpoint ("annotation.without-hostname.internal" , "A" , "1.2.3.4" ).
716
729
WithLabel (endpoint .ResourceLabelKey , "httproute/default/without-hostname" ),
717
730
newTestEndpoint ("annotation.with-hostname.internal" , "A" , "1.2.3.4" ).
@@ -861,6 +874,64 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
861
874
WithLabel (endpoint .ResourceLabelKey , "httproute/default/valid-ttl" ),
862
875
},
863
876
},
877
+ {
878
+ title : "TTLGateway" ,
879
+ config : Config {},
880
+ namespaces : namespaces ("default" ),
881
+ gateways : []* v1beta1.Gateway {{
882
+ ObjectMeta : metav1.ObjectMeta {
883
+ Name : "test" ,
884
+ Namespace : "default" ,
885
+ Annotations : map [string ]string {ttlAnnotationKey : "15s" },
886
+ },
887
+ Spec : v1.GatewaySpec {
888
+ Listeners : []v1.Listener {{Protocol : v1 .HTTPProtocolType }},
889
+ },
890
+ Status : gatewayStatus ("1.2.3.4" ),
891
+ }},
892
+ routes : []* v1beta1.HTTPRoute {
893
+ {
894
+ ObjectMeta : metav1.ObjectMeta {
895
+ Name : "no-ttl" ,
896
+ Namespace : "default" ,
897
+ },
898
+ Spec : v1.HTTPRouteSpec {
899
+ Hostnames : hostnames ("no-ttl.internal" ),
900
+ },
901
+ Status : httpRouteStatus (gwParentRef ("default" , "test" )),
902
+ },
903
+ {
904
+ ObjectMeta : metav1.ObjectMeta {
905
+ Name : "longer-ttl" ,
906
+ Namespace : "default" ,
907
+ Annotations : map [string ]string {ttlAnnotationKey : "20s" },
908
+ },
909
+ Spec : v1.HTTPRouteSpec {
910
+ Hostnames : hostnames ("longer-ttl.internal" ),
911
+ },
912
+ Status : httpRouteStatus (gwParentRef ("default" , "test" )),
913
+ },
914
+ {
915
+ ObjectMeta : metav1.ObjectMeta {
916
+ Name : "shorter-ttl" ,
917
+ Namespace : "default" ,
918
+ Annotations : map [string ]string {ttlAnnotationKey : "5s" },
919
+ },
920
+ Spec : v1.HTTPRouteSpec {
921
+ Hostnames : hostnames ("shorter-ttl.internal" ),
922
+ },
923
+ Status : httpRouteStatus (gwParentRef ("default" , "test" )),
924
+ },
925
+ },
926
+ endpoints : []* endpoint.Endpoint {
927
+ newTestEndpointWithTTL ("no-ttl.internal" , "A" , 15 , "1.2.3.4" ).
928
+ WithLabel (endpoint .ResourceLabelKey , "httproute/default/no-ttl" ),
929
+ newTestEndpointWithTTL ("longer-ttl.internal" , "A" , 15 , "1.2.3.4" ).
930
+ WithLabel (endpoint .ResourceLabelKey , "httproute/default/longer-ttl" ),
931
+ newTestEndpointWithTTL ("shorter-ttl.internal" , "A" , 5 , "1.2.3.4" ).
932
+ WithLabel (endpoint .ResourceLabelKey , "httproute/default/shorter-ttl" ),
933
+ },
934
+ },
864
935
{
865
936
title : "ProviderAnnotations" ,
866
937
config : Config {},
@@ -893,6 +964,61 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
893
964
WithSetIdentifier ("test-set-identifier" ),
894
965
},
895
966
},
967
+ {
968
+ title : "ProviderAnnotationsGateway" ,
969
+ config : Config {},
970
+ namespaces : namespaces ("default" ),
971
+ gateways : []* v1beta1.Gateway {{
972
+ ObjectMeta : metav1.ObjectMeta {
973
+ Name : "test" ,
974
+ Namespace : "default" ,
975
+ Annotations : map [string ]string {
976
+ SetIdentifierKey : "gateway" ,
977
+ "external-dns.alpha.kubernetes.io/webhook-property" : "gateway" ,
978
+ },
979
+ },
980
+ Spec : v1.GatewaySpec {
981
+ Listeners : []v1.Listener {{Protocol : v1 .HTTPProtocolType }},
982
+ },
983
+ Status : gatewayStatus ("1.2.3.4" ),
984
+ }},
985
+ routes : []* v1beta1.HTTPRoute {
986
+ {
987
+ ObjectMeta : metav1.ObjectMeta {
988
+ Name : "with-provider-annotations" ,
989
+ Namespace : "default" ,
990
+ Annotations : map [string ]string {
991
+ SetIdentifierKey : "route" ,
992
+ "external-dns.alpha.kubernetes.io/webhook-property" : "route" ,
993
+ },
994
+ },
995
+ Spec : v1.HTTPRouteSpec {
996
+ Hostnames : hostnames ("with-provider-annotations.internal" ),
997
+ },
998
+ Status : httpRouteStatus (gwParentRef ("default" , "test" )),
999
+ },
1000
+ {
1001
+ ObjectMeta : metav1.ObjectMeta {
1002
+ Name : "without-provider-annotations" ,
1003
+ Namespace : "default" ,
1004
+ },
1005
+ Spec : v1.HTTPRouteSpec {
1006
+ Hostnames : hostnames ("without-provider-annotations.internal" ),
1007
+ },
1008
+ Status : httpRouteStatus (gwParentRef ("default" , "test" )),
1009
+ },
1010
+ },
1011
+ endpoints : []* endpoint.Endpoint {
1012
+ newTestEndpoint ("with-provider-annotations.internal" , "A" , "1.2.3.4" ).
1013
+ WithLabel (endpoint .ResourceLabelKey , "httproute/default/with-provider-annotations" ).
1014
+ WithProviderSpecific ("webhook/property" , "route" ).
1015
+ WithSetIdentifier ("route" ),
1016
+ newTestEndpoint ("without-provider-annotations.internal" , "A" , "1.2.3.4" ).
1017
+ WithLabel (endpoint .ResourceLabelKey , "httproute/default/without-provider-annotations" ).
1018
+ WithProviderSpecific ("webhook/property" , "gateway" ).
1019
+ WithSetIdentifier ("gateway" ),
1020
+ },
1021
+ },
896
1022
{
897
1023
title : "DifferentHostnameDifferentGateway" ,
898
1024
config : Config {},
@@ -1153,6 +1279,65 @@ func TestGatewayHTTPRouteSourceEndpoints(t *testing.T) {
1153
1279
WithLabel (endpoint .ResourceLabelKey , "httproute/route-namespace/test" ),
1154
1280
},
1155
1281
},
1282
+ {
1283
+ title : "DualstackAnnotation" ,
1284
+ config : Config {},
1285
+ namespaces : namespaces ("default" ),
1286
+ gateways : []* v1beta1.Gateway {{
1287
+ ObjectMeta : objectMeta ("default" , "test" ),
1288
+ Spec : v1.GatewaySpec {
1289
+ Listeners : []v1.Listener {{Protocol : v1 .HTTPProtocolType }},
1290
+ },
1291
+ Status : gatewayStatus ("1.2.3.4" ),
1292
+ }},
1293
+ routes : []* v1beta1.HTTPRoute {
1294
+ {
1295
+ ObjectMeta : metav1.ObjectMeta {
1296
+ Name : "invalid-dualstack-annotation" ,
1297
+ Namespace : "default" ,
1298
+ Annotations : map [string ]string {
1299
+ gatewayAPIDualstackAnnotationKey : "invalid" ,
1300
+ },
1301
+ },
1302
+ Spec : v1.HTTPRouteSpec {
1303
+ Hostnames : hostnames ("invalid-dualstack-annotation.internal" ),
1304
+ },
1305
+ Status : httpRouteStatus (gwParentRef ("default" , "test" )),
1306
+ },
1307
+ {
1308
+ ObjectMeta : metav1.ObjectMeta {
1309
+ Name : "with-dualstack-annotation" ,
1310
+ Namespace : "default" ,
1311
+ Annotations : map [string ]string {
1312
+ gatewayAPIDualstackAnnotationKey : gatewayAPIDualstackAnnotationValue ,
1313
+ },
1314
+ },
1315
+ Spec : v1.HTTPRouteSpec {
1316
+ Hostnames : hostnames ("with-dualstack-annotation.internal" ),
1317
+ },
1318
+ Status : httpRouteStatus (gwParentRef ("default" , "test" )),
1319
+ },
1320
+ {
1321
+ ObjectMeta : metav1.ObjectMeta {
1322
+ Name : "without-dualstack-annotation" ,
1323
+ Namespace : "default" ,
1324
+ },
1325
+ Spec : v1.HTTPRouteSpec {
1326
+ Hostnames : hostnames ("without-dualstack-annotation.internal" ),
1327
+ },
1328
+ Status : httpRouteStatus (gwParentRef ("default" , "test" )),
1329
+ },
1330
+ },
1331
+ endpoints : []* endpoint.Endpoint {
1332
+ newTestEndpoint ("invalid-dualstack-annotation.internal" , "A" , "1.2.3.4" ).
1333
+ WithLabel (endpoint .ResourceLabelKey , "httproute/default/invalid-dualstack-annotation" ),
1334
+ newTestEndpoint ("with-dualstack-annotation.internal" , "A" , "1.2.3.4" ).
1335
+ WithLabel (endpoint .ResourceLabelKey , "httproute/default/with-dualstack-annotation" ).
1336
+ WithLabel (endpoint .DualstackLabelKey , "true" ),
1337
+ newTestEndpoint ("without-dualstack-annotation.internal" , "A" , "1.2.3.4" ).
1338
+ WithLabel (endpoint .ResourceLabelKey , "httproute/default/without-dualstack-annotation" ),
1339
+ },
1340
+ },
1156
1341
}
1157
1342
for _ , tt := range tests {
1158
1343
tt := tt
0 commit comments