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:
parent
6fc80cda96
commit
4225bbc35f
@ -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),
|
||||
|
12
starlark/types/testdata/hcl.star
vendored
12
starlark/types/testdata/hcl.star
vendored
@ -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' + \
|
||||
|
Loading…
Reference in New Issue
Block a user