Skip to content

Commit 2fb7a55

Browse files
author
Doyoon Kim
authored
Fix target group discovery logic (#587)
1 parent bcf7185 commit 2fb7a55

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

pkg/deploy/lattice/target_group_manager.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"github.com/aws/aws-sdk-go/service/vpclattice"
1212

1313
pkg_aws "github.com/aws/aws-application-networking-k8s/pkg/aws"
14-
"github.com/aws/aws-application-networking-k8s/pkg/config"
1514
model "github.com/aws/aws-application-networking-k8s/pkg/model/lattice"
1615
"github.com/aws/aws-application-networking-k8s/pkg/utils/gwlog"
1716
"reflect"
@@ -256,19 +255,15 @@ func (s *defaultTargetGroupManager) List(ctx context.Context) ([]tgListOutput, e
256255
if len(resp) == 0 {
257256
return nil, nil
258257
}
259-
validTgs := utils.SliceFilter(resp, func(tg *vpclattice.TargetGroupSummary) bool {
260-
return aws.StringValue(tg.VpcIdentifier) == config.VpcID &&
261-
aws.StringValue(tg.Type) == vpclattice.TargetGroupTypeIp
262-
})
263-
tgArns := utils.SliceMap(validTgs, func(tg *vpclattice.TargetGroupSummary) string {
258+
tgArns := utils.SliceMap(resp, func(tg *vpclattice.TargetGroupSummary) string {
264259
return aws.StringValue(tg.Arn)
265260
})
266261
tgArnToTagsMap, err := s.cloud.Tagging().GetTagsForArns(ctx, tgArns)
267262

268263
if err != nil {
269264
return nil, err
270265
}
271-
for _, tg := range validTgs {
266+
for _, tg := range resp {
272267
tgList = append(tgList, tgListOutput{
273268
tgSummary: tg,
274269
tags: tgArnToTagsMap[*tg.Arn],

pkg/deploy/lattice/target_group_manager_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -778,6 +778,8 @@ func Test_ListTG_TGsExist(t *testing.T) {
778778
id := "123456789"
779779
name1 := "test1"
780780
config.VpcID = "vpc-id"
781+
externalVpc := "external-vpc-id"
782+
781783
config.ClusterName = "cluster-name"
782784
tgType := vpclattice.TargetGroupTypeIp
783785
tg1 := &vpclattice.TargetGroupSummary{
@@ -792,7 +794,7 @@ func Test_ListTG_TGsExist(t *testing.T) {
792794
Arn: &arn,
793795
Id: &id,
794796
Name: &name2,
795-
VpcIdentifier: &config.VpcID,
797+
VpcIdentifier: &externalVpc,
796798
Type: &tgType,
797799
}
798800
listTGOutput := []*vpclattice.TargetGroupSummary{tg1, tg2}

0 commit comments

Comments
 (0)