Skip to content

Commit

Permalink
minor refactors
Browse files Browse the repository at this point in the history
  • Loading branch information
bigkraig committed Sep 30, 2018
1 parent 7f5bacd commit e1fc19c
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions internal/alb/tags/tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ func (c *controller) Reconcile(ctx context.Context, desired *Tags) error {
var err error

if strings.HasPrefix(desired.Arn, "arn:aws:elasticloadbalancing") {
current, err = c.elbTags(ctx, desired.Arn)
if err != nil {
if current, err = c.elbTags(ctx, desired.Arn); err != nil {
return err
}
}
Expand Down Expand Up @@ -116,16 +115,14 @@ func (c *controller) Reconcile(ctx context.Context, desired *Tags) error {
}

func (c *controller) elbTags(ctx context.Context, arn string) (t *Tags, err error) {
var r *elbv2.DescribeTagsOutput
t = NewTags()

resp, err := c.elbv2.DescribeTags(&elbv2.DescribeTagsInput{ResourceArns: []*string{aws.String(arn)}})
if err != nil {
return
}

for _, tagDescription := range resp.TagDescriptions {
for _, tag := range tagDescription.Tags {
t.Tags[aws.StringValue(tag.Key)] = aws.StringValue(tag.Value)
if r, err = c.elbv2.DescribeTags(&elbv2.DescribeTagsInput{ResourceArns: []*string{aws.String(arn)}}); err == nil {
for _, tagDescription := range r.TagDescriptions {
for _, tag := range tagDescription.Tags {
t.Tags[aws.StringValue(tag.Key)] = aws.StringValue(tag.Value)
}
}
}

Expand Down

0 comments on commit e1fc19c

Please sign in to comment.