diff --git a/starlark/types/hcl.go b/starlark/types/hcl.go index 526989b..08229dc 100644 --- a/starlark/types/hcl.go +++ b/starlark/types/hcl.go @@ -256,8 +256,7 @@ func appendTokensForValue(val starlark.Value, toks hclwrite.Tokens) hclwrite.Tok Bytes: []byte(srcStr), }) case starlark.Int: - bf := v.BigInt() - srcStr := bf.Text('2') + srcStr := fmt.Sprintf("%d", v) toks = append(toks, &hclwrite.Token{ Type: hclsyntax.TokenNumberLit, Bytes: []byte(srcStr), diff --git a/starlark/types/testdata/hcl.star b/starlark/types/testdata/hcl.star index 0500173..e502dfd 100644 --- a/starlark/types/testdata/hcl.star +++ b/starlark/types/testdata/hcl.star @@ -22,6 +22,11 @@ m.bucket = "main-storage" m.role = "roles/storage.objectAdmin" m.member = "serviceAccount:%s" % sa.email +addr = google.resource.compute_global_address("test") +addr.purpose = "VPC_PEERING" +addr.address_type = "INTERNAL" +addr.prefix_length = 16 + # hcl with interpoaltion assert.eq(hcl(google), "" + 'provider "google" {\n' + \ @@ -29,6 +34,13 @@ assert.eq(hcl(google), "" + ' version = "3.16.0"\n' + \ '}\n' + \ '\n' + \ +'resource "google_compute_global_address" "test" {\n' + \ +' provider = google.default\n' + \ +' address_type = "INTERNAL"\n' + \ +' prefix_length = 16\n' + \ +' purpose = "VPC_PEERING"\n' + \ +'}\n' + \ +'\n' + \ 'resource "google_service_account" "sa" {\n' + \ ' provider = google.default\n' + \ ' account_id = "service-account"\n' + \