Skip to content

Commit

Permalink
Renamed searchTag in tagExists
Browse files Browse the repository at this point in the history
Fixed a bug in the tagExists function
Fix a bug in the VSCode launch configuration
  • Loading branch information
alessandrolattao committed Mar 24, 2020
1 parent 4776928 commit 960a8f7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"eu-west-1",
"-tag",
"Name",
"-reverse"
"-untagged"
]
}
]
Expand Down
6 changes: 5 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,11 @@ func main() {
for _, resource := range resourcesOutput.ResourceTagMappingList {

// analyze tags
tagFound := searchTag(resource.Tags, tagKeyFlag)
tagFound := tagExists(resource.Tags, tagKeyFlag)

if tagFound {
fmt.Println("tag trovato in ")
}

// if the resource is tagged and I want untagged resource then skip
if tagFound && !*untaggedFlag {
Expand Down
6 changes: 3 additions & 3 deletions tags.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package main

import "github.com/aws/aws-sdk-go/service/resourcegroupstaggingapi"

// searchTag looks for tagKey between tags
func searchTag(tags []*resourcegroupstaggingapi.Tag, tagKey *string) bool {
// tagExists looks for tagKey between tags
func tagExists(tags []*resourcegroupstaggingapi.Tag, tagKey *string) bool {
for _, tag := range tags {
if *tag.Key != *tagKey {
if *tag.Key == *tagKey {
return true
}
}
Expand Down

0 comments on commit 960a8f7

Please sign in to comment.