@@ -19,7 +19,7 @@ import (
1919elbv2model "sigs.k8s.io/aws-load-balancer-controller/pkg/model/elbv2"
2020)
2121
22- func (t * defaultModelBuildTask ) buildListener (ctx context.Context , lbARN core.StringToken , port int64 , config listenPortConfig , ingList []* networking. Ingress ) (* elbv2model.Listener , error ) {
22+ func (t * defaultModelBuildTask ) buildListener (ctx context.Context , lbARN core.StringToken , port int64 , config listenPortConfig , ingList []ClassifiedIngress ) (* elbv2model.Listener , error ) {
2323lsSpec , err := t .buildListenerSpec (ctx , lbARN , port , config , ingList )
2424if err != nil {
2525return nil , err
@@ -29,12 +29,12 @@ func (t *defaultModelBuildTask) buildListener(ctx context.Context, lbARN core.St
2929return ls , nil
3030}
3131
32- func (t * defaultModelBuildTask ) buildListenerSpec (ctx context.Context , lbARN core.StringToken , port int64 , config listenPortConfig , ingList []* networking. Ingress ) (elbv2model.ListenerSpec , error ) {
32+ func (t * defaultModelBuildTask ) buildListenerSpec (ctx context.Context , lbARN core.StringToken , port int64 , config listenPortConfig , ingList []ClassifiedIngress ) (elbv2model.ListenerSpec , error ) {
3333defaultActions , err := t .buildListenerDefaultActions (ctx , config .protocol , ingList )
3434if err != nil {
3535return elbv2model.ListenerSpec {}, err
3636}
37- tags , err := t .modelBuildListenerTags (ctx , ingList )
37+ tags , err := t .buildListenerTags (ctx , ingList )
3838if err != nil {
3939return elbv2model.ListenerSpec {}, err
4040}
@@ -55,14 +55,14 @@ func (t *defaultModelBuildTask) buildListenerSpec(ctx context.Context, lbARN cor
5555}, nil
5656}
5757
58- func (t * defaultModelBuildTask ) buildListenerDefaultActions (ctx context.Context , protocol elbv2model.Protocol , ingList []* networking. Ingress ) ([]elbv2model.Action , error ) {
58+ func (t * defaultModelBuildTask ) buildListenerDefaultActions (ctx context.Context , protocol elbv2model.Protocol , ingList []ClassifiedIngress ) ([]elbv2model.Action , error ) {
5959if t .sslRedirectConfig != nil && protocol == elbv2model .ProtocolHTTP {
6060return []elbv2model.Action {t .buildSSLRedirectAction (ctx , * t .sslRedirectConfig )}, nil
6161}
6262
63- ingsWithDefaultBackend := make ([]* networking. Ingress , 0 , len (ingList ))
63+ ingsWithDefaultBackend := make ([]ClassifiedIngress , 0 , len (ingList ))
6464for _ , ing := range ingList {
65- if ing .Spec .Backend != nil {
65+ if ing .Ing . Spec .Backend != nil {
6666ingsWithDefaultBackend = append (ingsWithDefaultBackend , ing )
6767}
6868}
@@ -73,12 +73,12 @@ func (t *defaultModelBuildTask) buildListenerDefaultActions(ctx context.Context,
7373if len (ingsWithDefaultBackend ) > 1 {
7474ingKeys := make ([]types.NamespacedName , 0 , len (ingsWithDefaultBackend ))
7575for _ , ing := range ingsWithDefaultBackend {
76- ingKeys = append (ingKeys , k8s .NamespacedName (ing ))
76+ ingKeys = append (ingKeys , k8s .NamespacedName (ing . Ing ))
7777}
7878return nil , errors .Errorf ("multiple ingress defined default backend: %v" , ingKeys )
7979}
8080ing := ingsWithDefaultBackend [0 ]
81- enhancedBackend , err := t .enhancedBackendBuilder .Build (ctx , ing , * ing .Spec .Backend ,
81+ enhancedBackend , err := t .enhancedBackendBuilder .Build (ctx , ing . Ing , * ing . Ing .Spec .Backend ,
8282WithLoadBackendServices (true , t .backendServices ),
8383WithLoadAuthConfig (true ))
8484if err != nil {
@@ -87,6 +87,14 @@ func (t *defaultModelBuildTask) buildListenerDefaultActions(ctx context.Context,
8787return t .buildActions (ctx , protocol , ing , enhancedBackend )
8888}
8989
90+ func (t * defaultModelBuildTask ) buildListenerTags (_ context.Context , ingList []ClassifiedIngress ) (map [string ]string , error ) {
91+ ingGroupTags , err := t .buildIngressGroupResourceTags (ingList )
92+ if err != nil {
93+ return nil , err
94+ }
95+ return algorithm .MergeStringMap (t .defaultTags , ingGroupTags ), nil
96+ }
97+
9098// the listen port config for specific listener port.
9199type listenPortConfig struct {
92100protocol elbv2model.Protocol
@@ -227,26 +235,3 @@ func (t *defaultModelBuildTask) computeIngressExplicitSSLPolicy(_ context.Contex
227235}
228236return & rawSSLPolicy
229237}
230-
231- func (t * defaultModelBuildTask ) modelBuildListenerTags (_ context.Context , ingList []* networking.Ingress ) (map [string ]string , error ) {
232- annotationTags := make (map [string ]string )
233- for _ , ing := range ingList {
234- var rawTags map [string ]string
235- if _ , err := t .annotationParser .ParseStringMapAnnotation (annotations .IngressSuffixTags , & rawTags , ing .Annotations ); err != nil {
236- return nil , err
237- }
238- for tagKey , tagValue := range rawTags {
239- if t .externalManagedTags .Has (tagKey ) {
240- return nil , errors .Errorf ("external managed tag key %v cannot be specified on Ingress %v" ,
241- tagKey , k8s .NamespacedName (ing ).String ())
242- }
243-
244- if existingTagValue , exists := annotationTags [tagKey ]; exists && existingTagValue != tagValue {
245- return nil , errors .Errorf ("conflicting tag %v: %v | %v" , tagKey , existingTagValue , tagValue )
246- }
247- annotationTags [tagKey ] = tagValue
248- }
249- }
250- mergedTags := algorithm .MergeStringMap (t .defaultTags , annotationTags )
251- return mergedTags , nil
252- }
0 commit comments