Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions testdata/basic.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<th>RESOURCE</th>
</tr>
<tr>
<td>add</td>
<td>add (7)</td>
<td>
<ul>
<li><code>github_repository.terraform_plan_summary</code></li>
Expand All @@ -24,7 +24,7 @@
<th>OUTPUT</th>
</tr>
<tr>
<td>add</td>
<td>add (1)</td>
<td>
<ul>
<li><code>terraform_plan_summary_repository_name</code></li>
Expand Down
24 changes: 12 additions & 12 deletions testdata/basic.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
| CHANGE | RESOURCE |
|--------|------------------------------------------------------------------------|
| add | `github_repository.terraform_plan_summary` |
| | `module.github["demo-repository"].github_branch.development` |
| | `module.github["demo-repository"].github_branch.main` |
| | `module.github["demo-repository"].github_repository.repository` |
| | `module.github["terraform-plan-summary"].github_branch.development` |
| | `module.github["terraform-plan-summary"].github_branch.main` |
| | `module.github["terraform-plan-summary"].github_repository.repository` |
| CHANGE | RESOURCE |
|---------|------------------------------------------------------------------------|
| add (7) | `github_repository.terraform_plan_summary` |
| | `module.github["demo-repository"].github_branch.development` |
| | `module.github["demo-repository"].github_branch.main` |
| | `module.github["demo-repository"].github_repository.repository` |
| | `module.github["terraform-plan-summary"].github_branch.development` |
| | `module.github["terraform-plan-summary"].github_branch.main` |
| | `module.github["terraform-plan-summary"].github_repository.repository` |

| CHANGE | OUTPUT |
|--------|------------------------------------------|
| add | `terraform_plan_summary_repository_name` |
| CHANGE | OUTPUT |
|---------|------------------------------------------|
| add (1) | `terraform_plan_summary_repository_name` |
2 changes: 1 addition & 1 deletion writer/html_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ func TestHTMLWriterWithMockFileSystem(t *testing.T) {
<th>RESOURCE</th>
</tr>{{ range $change, $resources := .ResourceChanges }}{{ $length := len $resources }}{{ if gt $length 0 }}
<tr>
<td>{{ $change }}</td>
<td>{{ $change }} ({{ len $resources }})</td>
<td>
<ul>{{ range $i, $r := $resources }}
<li><code>{{ $r.Address }}</code></li>{{ end }}
Expand Down
10 changes: 6 additions & 4 deletions writer/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@ func (t TableWriter) Write(writer io.Writer) error {
tableString := make([][]string, 0, 4)
for _, change := range tableOrder {
changedResources := t.changes[change]
resourceCount := len(changedResources)
for _, changedResource := range changedResources {
if t.mdEnabled {
tableString = append(tableString, []string{change, fmt.Sprintf("`%s`", changedResource.Address)})
tableString = append(tableString, []string{fmt.Sprintf("%s (%d)", change, resourceCount), fmt.Sprintf("`%s`", changedResource.Address)})
} else {
tableString = append(tableString, []string{change, changedResource.Address})
tableString = append(tableString, []string{fmt.Sprintf("%s (%d)", change, resourceCount), changedResource.Address})
}
}
}
Expand All @@ -49,11 +50,12 @@ func (t TableWriter) Write(writer io.Writer) error {
tableString = make([][]string, 0, 4)
for _, change := range tableOrder {
changedOutputs := t.outputChanges[change]
outputCount := len(changedOutputs)
for _, changedOutput := range changedOutputs {
if t.mdEnabled {
tableString = append(tableString, []string{change, fmt.Sprintf("`%s`", changedOutput)})
tableString = append(tableString, []string{fmt.Sprintf("%s (%d)", change, outputCount), fmt.Sprintf("`%s`", changedOutput)})
} else {
tableString = append(tableString, []string{change, changedOutput})
tableString = append(tableString, []string{fmt.Sprintf("%s (%d)", change, outputCount), changedOutput})
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion writer/templates/outputChanges.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<th>OUTPUT</th>
</tr>{{ range $change, $outputs := .OutputChanges }}{{ $length := len $outputs }}{{ if gt $length 0 }}
<tr>
<td>{{ $change }}</td>
<td>{{ $change }} ({{ len $outputs }})</td>
<td>
<ul>{{ range $i, $o := $outputs }}
<li><code>{{ $o }}</code></li>{{ end }}
Expand Down
2 changes: 1 addition & 1 deletion writer/templates/resourceChanges.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<th>RESOURCE</th>
</tr>{{ range $change, $resources := .ResourceChanges }}{{ $length := len $resources }}{{ if gt $length 0 }}
<tr>
<td>{{ $change }}</td>
<td>{{ $change }} ({{ len $resources }})</td>
<td>
<ul>{{ range $i, $r := $resources }}
<li><code>{{ $r.Address }}</code></li>{{ end }}
Expand Down