Skip to content

Commit

Permalink
resource account: include AccountName as tag by default
Browse files Browse the repository at this point in the history
  • Loading branch information
dschofie committed Jul 3, 2024
1 parent 7885313 commit 81a7d4c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion resource/account.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func (a Account) IsProvisioned() bool {
}

func (a Account) AllTags() []string {
var tags []string
tags := []string{"AccountName=" + a.AccountName}
tags = append(tags, a.Tags...)
if a.Parent != nil {
tags = append(tags, a.Parent.AllTags()...)
Expand Down
18 changes: 17 additions & 1 deletion resourceoperation/organization_unit.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"context"
"fmt"
"log"
"strings"
"text/template"

"github.com/fatih/color"
Expand Down Expand Up @@ -473,6 +474,10 @@ func diffTags(taggable Taggable) (added, removed []string) {

for _, tag := range taggable.AllTags() {
if _, ok := oldMap[tag]; !ok {
if ignorableTag(tag) {
continue
}

if contains(added, tag) {
// There can be duplicates when tags are inherited from an OU
continue
Expand Down Expand Up @@ -514,9 +519,20 @@ func ignorableTag(tag string) bool {
ignorableTags := map[string]struct{}{
"TelophaseManaged=true": {},
}
ignorableKeys := map[string]struct{}{
"AccountName": {},
}

_, ok := ignorableTags[tag]
return ok
if ok {
return true
}
fmt.Println("checking tag: ", tag)
if _, ok := ignorableKeys[strings.Split(tag, "=")[0]]; ok {
return true
}
fmt.Println("tag passed", tag)
return false
}

func oneOf(check string, slc []string) bool {
Expand Down

0 comments on commit 81a7d4c

Please sign in to comment.