Skip to content

Commit 9d0faa2

Browse files
committed
Strip off extra \n in hcl encoded variables
They don't change the value, but they do currently end up in the UI
1 parent bf83b43 commit 9d0faa2

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

command/hcl_printer.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,13 @@ func encodeHCL(i interface{}) ([]byte, error) {
3535
// now strip that first assignment off
3636
eq := regexp.MustCompile(`=\s+`).FindIndex(hcl)
3737

38-
return hcl[eq[1]:], nil
38+
// strip of an extra \n if it's there
39+
end := len(hcl)
40+
if hcl[end-1] == '\n' {
41+
end -= 1
42+
}
43+
44+
return hcl[eq[1]:end], nil
3945
}
4046

4147
type encodeState struct {

0 commit comments

Comments
 (0)