File tree Expand file tree Collapse file tree 3 files changed +12
-3
lines changed
Expand file tree Collapse file tree 3 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -68,6 +68,7 @@ resource "mongodbatlas_cluster" "all" {
6868 value = " label val 2"
6969 }
7070 timeouts {
71+ # comments in timeouts are also copied
7172 create = " 60m"
7273 update = " 50m"
7374 delete = " 30m"
Original file line number Diff line number Diff line change @@ -37,7 +37,6 @@ resource "mongodbatlas_advanced_cluster" "basictimeouts" {
3737 }]
3838 }]
3939 timeouts = {
40-
4140 create = " 60m"
4241 }
4342
@@ -69,7 +68,7 @@ resource "mongodbatlas_advanced_cluster" "all" {
6968 " Label 2" = " label val 2"
7069 }
7170 timeouts = {
72-
71+ # comments in timeouts are also copied
7372 create = " 60m"
7473 update = " 50m"
7574 delete = " 30m"
Original file line number Diff line number Diff line change @@ -98,16 +98,25 @@ func TokensArraySingle(body *hclwrite.Body) hclwrite.Tokens {
9898
9999// TokensObject creates an object.
100100func TokensObject (body * hclwrite.Body ) hclwrite.Tokens {
101+ tokens := RemoveLeadingNewline (body .BuildTokens (nil ))
101102 ret := hclwrite.Tokens {
102103 {Type : hclsyntax .TokenOBrace , Bytes : []byte ("{" )},
103104 {Type : hclsyntax .TokenNewline , Bytes : []byte ("\n " )},
104105 }
105- ret = append (ret , body . BuildTokens ( nil ) ... )
106+ ret = append (ret , tokens ... )
106107 ret = append (ret ,
107108 & hclwrite.Token {Type : hclsyntax .TokenCBrace , Bytes : []byte ("}" )})
108109 return ret
109110}
110111
112+ // RemoveLeadingNewline removes the first newline if it exists to make the output prettier.
113+ func RemoveLeadingNewline (tokens hclwrite.Tokens ) hclwrite.Tokens {
114+ if len (tokens ) > 0 && tokens [0 ].Type == hclsyntax .TokenNewline {
115+ return tokens [1 :]
116+ }
117+ return tokens
118+ }
119+
111120// AppendComment adds a comment at the end of the body.
112121func AppendComment (body * hclwrite.Body , comment string ) {
113122 tokens := hclwrite.Tokens {
You can’t perform that action at this time.
0 commit comments