Skip to content

Commit 4225bbc

Browse files
committed
starlark: types, fix HCL int encoding
1 parent 6fc80cd commit 4225bbc

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

starlark/types/hcl.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,7 @@ func appendTokensForValue(val starlark.Value, toks hclwrite.Tokens) hclwrite.Tok
256256
Bytes: []byte(srcStr),
257257
})
258258
case starlark.Int:
259-
bf := v.BigInt()
260-
srcStr := bf.Text('2')
259+
srcStr := fmt.Sprintf("%d", v)
261260
toks = append(toks, &hclwrite.Token{
262261
Type: hclsyntax.TokenNumberLit,
263262
Bytes: []byte(srcStr),

starlark/types/testdata/hcl.star

+12
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,25 @@ m.bucket = "main-storage"
2222
m.role = "roles/storage.objectAdmin"
2323
m.member = "serviceAccount:%s" % sa.email
2424

25+
addr = google.resource.compute_global_address("test")
26+
addr.purpose = "VPC_PEERING"
27+
addr.address_type = "INTERNAL"
28+
addr.prefix_length = 16
29+
2530
# hcl with interpoaltion
2631
assert.eq(hcl(google), "" +
2732
'provider "google" {\n' + \
2833
' alias = "default"\n' + \
2934
' version = "3.16.0"\n' + \
3035
'}\n' + \
3136
'\n' + \
37+
'resource "google_compute_global_address" "test" {\n' + \
38+
' provider = google.default\n' + \
39+
' address_type = "INTERNAL"\n' + \
40+
' prefix_length = 16\n' + \
41+
' purpose = "VPC_PEERING"\n' + \
42+
'}\n' + \
43+
'\n' + \
3244
'resource "google_service_account" "sa" {\n' + \
3345
' provider = google.default\n' + \
3446
' account_id = "service-account"\n' + \

0 commit comments

Comments
 (0)