Skip to content

Commit

Permalink
Merge pull request #97 from JackFlukinger/fix-incorrect-visualization
Browse files Browse the repository at this point in the history
  • Loading branch information
im2nguyen authored Mar 5, 2022
2 parents ac4a0f6 + 1eb3540 commit 513a88a
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
6 changes: 4 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
rover
build/rover
.DS_Store
rover.zip
plan.out

# Ignore generated terraform files
.terraform**

.idea/
.idea/

build/
4 changes: 4 additions & 0 deletions example/multiple-files-same-resource-type-test/file-one.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
resource "random_integer" "one" {
min = 1
max = 3
}
4 changes: 4 additions & 0 deletions example/multiple-files-same-resource-type-test/file-two.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
resource "random_integer" "two" {
min = 1
max = 4
}
10 changes: 9 additions & 1 deletion graph.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,17 @@ func (r *rover) addNodes(base string, parent string, nodeMap map[string]Node, re
label := l[len(l)-1]

midParent := parent

if midParent == mid {
midParent = strings.TrimSuffix(midParent, fmt.Sprintf(".%v", label))
midParent = nodeMap[midParent].Data.Parent
}

if nodeMap[midParent].Data.Type == ResourceTypeFile {
mid = fmt.Sprintf("%s {%s}", mid, nodeMap[parent].Data.Label)
}

//fmt.Printf(midParent + " - " + mid + "\n")

// Append resource type
nmo = append(nmo, mid)
nodeMap[mid] = Node{
Expand Down Expand Up @@ -145,6 +152,7 @@ func (r *rover) addNodes(base string, parent string, nodeMap map[string]Node, re
},
Classes: fmt.Sprintf("%s-name %s", re.Type, mrChange),
}
//fmt.Printf(id + " - " + mid + "\n")

nmo = append(nmo, r.addNodes(base, id, nodeMap, re.Children)...)

Expand Down

0 comments on commit 513a88a

Please # to comment.