1
1
mirror of https://github.com/mcuadros/ascode synced 2024-11-22 17:02:03 +01:00

starlark: types, fix HCL int encoding

This commit is contained in:
Máximo Cuadros 2020-04-30 22:12:38 +02:00
parent 6fc80cda96
commit 4225bbc35f
No known key found for this signature in database
GPG Key ID: 17A5DFEDC735AE4B
2 changed files with 13 additions and 2 deletions

@ -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),

@ -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' + \