Skip to content

Commit

Permalink
feat: Add iam_email and env_vars output to simple-sa submodule (#122)
Browse files Browse the repository at this point in the history
  • Loading branch information
q2w authored Jul 14, 2024
1 parent 6905817 commit ae592d2
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ docker_test_lint:
.PHONY: docker_generate_docs
docker_generate_docs:
docker run --rm -it \
-e ENABLE_BPMETADATA \
-v "$(CURDIR)":/workspace \
$(REGISTRY_URL)/${DOCKER_IMAGE_DEVELOPER_TOOLS}:${DOCKER_TAG_VERSION_DEVELOPER_TOOLS} \
/bin/bash -c 'source /usr/local/bin/task_helper_functions.sh && generate_docs'
Expand Down
2 changes: 2 additions & 0 deletions examples/simple_sa/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ This example shows how to use the `simple-sa` submodule.
| Name | Description |
|------|-------------|
| email | Service account email |
| env\_vars | Exported environment variables |
| iam\_email | IAM format service account email |

<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

Expand Down
10 changes: 10 additions & 0 deletions examples/simple_sa/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,13 @@ output "email" {
description = "Service account email"
value = module.sa.email
}

output "iam_email" {
description = "IAM format service account email"
value = module.sa.iam_email
}

output "env_vars" {
description = "Exported environment variables"
value = module.sa.env_vars
}
2 changes: 2 additions & 0 deletions modules/simple-sa/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ module "sa" {
| Name | Description |
|------|-------------|
| email | Service account email |
| env\_vars | Exported environment variables |
| iam\_email | IAM format service account email |
| id | Service account id and email |

<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
4 changes: 4 additions & 0 deletions modules/simple-sa/metadata.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ spec:
outputs:
- name: email
description: Service account email
- name: env_vars
description: Exported environment variables
- name: iam_email
description: IAM format service account email
- name: id
description: Service account id and email
requirements:
Expand Down
11 changes: 11 additions & 0 deletions modules/simple-sa/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,21 @@ output "email" {
value = google_service_account.sa.email
}

output "iam_email" {
description = "IAM format service account email"
value = google_service_account.sa.member
}

output "id" {
description = "Service account id and email"
value = {
id = google_service_account.sa.account_id,
email = google_service_account.sa.email
}
}

output "env_vars" {
description = "Exported environment variables"
value = { "SERVICE_ACCOUNT_EMAIL" : google_service_account.sa.email,
"SERVICE_ACCOUNT_IAM_EMAIL" : google_service_account.sa.member }
}
6 changes: 6 additions & 0 deletions test/integration/simple_sa/simple_sa_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ func TestSimpleSA(t *testing.T) {
for _, b := range bindings {
assert.Contains(expectedRoles, b.Get("bindings.role").String())
}

iam_email := sa.GetStringOutput("iam_email")
env_vars := sa.GetStringOutput("env_vars")
assert.Contains(iam_email, "serviceAccount:")
assert.Contains(env_vars, "SERVICE_ACCOUNT_EMAIL")
assert.Contains(env_vars, "SERVICE_ACCOUNT_IAM_EMAIL")
})
sa.Test()
}

0 comments on commit ae592d2

Please sign in to comment.