github.com/mcuadros/ascode@v1.3.1/starlark/types/testdata/hcl.star (about)

     1  load("assert.star", "assert")
     2  
     3  helm = tf.provider("helm", "1.0.0", "default")
     4  helm.kubernetes.token = "foo"
     5  
     6  # hcl
     7  assert.eq(hcl(helm), "" +
     8  'provider "helm" {\n' + \
     9  '  alias   = "default"\n' + \
    10  '  version = "1.0.0"\n\n' + \
    11  '  kubernetes {\n' + \
    12  '    token = "foo"\n' + \
    13  '  }\n' + \
    14  '}\n\n')
    15  
    16  google = tf.provider("google", "3.16.0", "default")
    17  sa = google.resource.service_account("sa")
    18  sa.account_id = "service-account"
    19  
    20  m = google.resource.storage_bucket_iam_member(sa.account_id+"-admin")
    21  m.bucket = "main-storage"
    22  m.role = "roles/storage.objectAdmin"
    23  m.member = "serviceAccount:%s" % sa.email
    24  
    25  addr = google.resource.compute_global_address("test")
    26  addr.purpose = "VPC_PEERING"
    27  addr.address_type = "INTERNAL"
    28  addr.prefix_length = 16
    29  
    30  # hcl with interpoaltion
    31  assert.eq(hcl(google), "" + 
    32  'provider "google" {\n' + \
    33  '  alias   = "default"\n' + \
    34  '  version = "3.16.0"\n' + \
    35  '}\n' + \
    36  '\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' + \
    44  'resource "google_service_account" "sa" {\n' + \
    45  '  provider   = google.default\n' + \
    46  '  account_id = "service-account"\n' + \
    47  '}\n' + \
    48  '\n' + \
    49  'resource "google_storage_bucket_iam_member" "service-account-admin" {\n' + \
    50  '  provider = google.default\n' + \
    51  '  bucket   = "main-storage"\n' + \
    52  '  member   = "serviceAccount:${google_service_account.sa.email}"\n' + \
    53  '  role     = "roles/storage.objectAdmin"\n' + \
    54  '}\n\n')
    55  
    56  # hcl with prefixed provider
    57  google = tf.provider("google", "3.16.0", "alias")
    58  google.set_prefix(True)
    59  
    60  sa = google.resource.service_account("sa")
    61  sa.account_id = "service-account"
    62  assert.eq(hcl(google), "" +
    63  'provider "google" {\n' + \
    64  '  alias   = "alias"\n' + \
    65  '  version = "3.16.0"\n' + \
    66  '}\n' + \
    67  '\n' + \
    68  'resource "google_service_account" "alias-sa" {\n' + \
    69  '  provider   = google.alias\n' + \
    70  '  account_id = "service-account"\n' + \
    71  '}\n\n')