Skip to content

Commit

Permalink
refactor: pass escapeHTML parameter to UnifiedDiffRenderer directly
Browse files Browse the repository at this point in the history
  • Loading branch information
takaishi committed Sep 13, 2023
1 parent 1d31e1b commit 24596a8
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cmd/terraform-j2md/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func run() int {
fmt.Fprintf(os.Stderr, "cannot parse input as Terraform plan JSON: %v", err)
return 1
}
if err = planData.Render(os.Stdout, escapeHTML); err != nil {
if err = planData.Render(os.Stdout); err != nil {
fmt.Fprintf(os.Stderr, "cannot render: %v", err)
return 1
}
Expand Down
5 changes: 1 addition & 4 deletions internal/terraform/plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ type Config struct {
EscapeHTML bool
}

var config Config

type ResourceChangeData struct {
ResourceChange *tfjson.ResourceChange
Renderer ResourceChangeDataRenderer
Expand All @@ -75,8 +73,7 @@ func (r ResourceChangeData) Header() string {
return r.Renderer.Header()
}

func (plan *PlanData) Render(w io.Writer, escapeHTML bool) error {
config.EscapeHTML = escapeHTML
func (plan *PlanData) Render(w io.Writer) error {
funcMap := template.FuncMap{
"codeFence": func() string {
return "````````"
Expand Down
4 changes: 2 additions & 2 deletions test/plan_test/plan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func Test_render(t *testing.T) {
}

got := bytes.Buffer{}
err = plan.Render(&got, true)
err = plan.Render(&got)
if (err != nil) != tt.wantErr {
t.Errorf("render() error = %v, wantErr %v", err, tt.wantErr)
return
Expand Down Expand Up @@ -127,7 +127,7 @@ func Test_render(t *testing.T) {
}

got := bytes.Buffer{}
err = plan.Render(&got, false)
err = plan.Render(&got)
if (err != nil) != tt.wantErr {
t.Errorf("render() error = %v, wantErr %v", err, tt.wantErr)
return
Expand Down

0 comments on commit 24596a8

Please sign in to comment.