Skip to content

Commit afbfe4f

Browse files
committed
fix quotes
1 parent 67065d0 commit afbfe4f

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

internal/convert/testdata/clu2adv/tags_labels_timeouts.out.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ resource "mongodbatlas_advanced_cluster" "all" {
6262
}]
6363
tags = {
6464
environment = "dev"
65-
Tag 2 = "Value 2"
65+
"Tag 2" = "Value 2"
6666
}
6767
labels = {
68-
label1 = "Val label 1"
69-
Label 2 = "label val 2"
68+
label1 = "Val label 1"
69+
"Label 2" = "label val 2"
7070
}
7171
timeouts = {
7272

internal/hcl/hcl.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,11 @@ func GetAttrString(attr *hclwrite.Attribute, errPrefix string) (string, error) {
6868
if !val.Type().Equals(cty.String) {
6969
return "", fmt.Errorf("%s: attribute is not a string", errPrefix)
7070
}
71-
return val.AsString(), nil
71+
str := val.AsString()
72+
if !hclsyntax.ValidIdentifier(str) {
73+
str = strconv.Quote(str)
74+
}
75+
return str, nil
7276
}
7377

7478
// TokensArray creates an array of objects.

0 commit comments

Comments
 (0)