Skip to content

Commit

Permalink
👍 Change snippet format to terraform fmt format
Browse files Browse the repository at this point in the history
  • Loading branch information
chroju committed May 8, 2018
1 parent 3e26695 commit 54c33e9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
15 changes: 14 additions & 1 deletion Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions scraping/tfresource.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package scraping

import (
"strings"

"github.com/hashicorp/hcl/hcl/printer"
)

type tfResourceArg struct {
Expand Down Expand Up @@ -63,6 +65,9 @@ func (t *TfResource) Snippet(needlessComment bool, requiredOnly bool) []string {
ret = append(ret, "resource \""+t.Name+"\" \"sample\" {")
ret = append(ret, printTfResourceArgsSnippet(t.Args, 1, needlessComment, requiredOnly)...)
ret = append(ret, "}")

formatted, _ := printer.Format([]byte(strings.Join(ret, "\n")))
ret = strings.Split(string(formatted), "\n")
return ret
}

Expand All @@ -84,8 +89,6 @@ func printTfResourceArgsSnippet(args []*tfResourceArg, indent int, needlessComme
} else {
ret = append(ret, spaces+arg.Name+" = "+"\""+"\"")
}

ret = append(ret, "")
}

return ret
Expand Down

0 comments on commit 54c33e9

Please sign in to comment.