From fa80759c0909405bcf99eabed2b938113bfe1c87 Mon Sep 17 00:00:00 2001 From: abhishek kumar tiwari Date: Tue, 10 Dec 2024 12:06:44 +0000 Subject: [PATCH] feat: add apphub_workload_uri output variable and update metadata (#451) --- autogen/outputs.tf.tmpl | 10 ++++++++++ modules/instance_template/metadata.display.yaml | 14 +++++++------- modules/mig/README.md | 1 + modules/mig/metadata.display.yaml | 8 ++++---- modules/mig/metadata.yaml | 6 ++++++ modules/mig/outputs.tf | 8 ++++++++ 6 files changed, 36 insertions(+), 11 deletions(-) diff --git a/autogen/outputs.tf.tmpl b/autogen/outputs.tf.tmpl index a0e36355..5abb642e 100644 --- a/autogen/outputs.tf.tmpl +++ b/autogen/outputs.tf.tmpl @@ -35,3 +35,13 @@ output "health_check_self_links" { description = "All self_links of healthchecks created for the instance group." value = local.healthchecks } +{% if mig %} + +output "apphub_workload_uri" { + value = { + workload_uri = "//compute.googleapis.com/projects${element(split("/projects", google_compute_region_instance_group_manager.mig.instance_group), 1)}" + workload_id = substr(join("-", [tostring(google_compute_region_instance_group_manager.mig.name), md5(tostring(google_compute_region_instance_group_manager.mig.self_link))]), 0, 63) + } + description = "Workload URI in CAIS style to be used by Apphub." +} +{% endif %} \ No newline at end of file diff --git a/modules/instance_template/metadata.display.yaml b/modules/instance_template/metadata.display.yaml index 46648999..365723b0 100644 --- a/modules/instance_template/metadata.display.yaml +++ b/modules/instance_template/metadata.display.yaml @@ -60,7 +60,7 @@ spec: description: name: description title: Description - invisible: false + level: 1 disk_encryption_key: name: disk_encryption_key title: Disk Encryption Key @@ -91,7 +91,7 @@ spec: instance_description: name: instance_description title: Instance Description - invisible: false + level: 1 ipv6_access_config: name: ipv6_access_config title: Ipv6 Access Config @@ -101,7 +101,7 @@ spec: machine_type: name: machine_type title: Machine Type - invisible: false + level: 1 maintenance_interval: name: maintenance_interval title: Maintenance Interval @@ -114,9 +114,9 @@ spec: name_prefix: name: name_prefix title: Name Prefix - invisible: false regexValidation: ^[a-z][a-z0-9-]{0,51}[a-z0-9]$ validation: Use lowercase letters, numbers, and hyphens. Start with a letter and end with letter/number. Must be 53 characters or fewer. + level: 1 network: name: network title: Network @@ -135,11 +135,11 @@ spec: project_id: name: project_id title: Project Id - invisible: false + level: 1 region: name: region title: Region - invisible: false + level: 1 resource_policies: name: resource_policies title: Resource Policies @@ -161,7 +161,7 @@ spec: spot: name: spot title: Spot - invisible: false + level: 1 spot_instance_termination_action: name: spot_instance_termination_action title: Spot Instance Termination Action diff --git a/modules/mig/README.md b/modules/mig/README.md index b8d59c4a..62be74c7 100644 --- a/modules/mig/README.md +++ b/modules/mig/README.md @@ -52,6 +52,7 @@ The current version is 2.X. The following guides are available to assist with up | Name | Description | |------|-------------| +| apphub\_workload\_uri | Workload URI in CAIS style to be used by Apphub. | | health\_check\_self\_links | All self\_links of healthchecks created for the instance group. | | instance\_group | Instance-group url of managed instance group | | instance\_group\_manager | An instance of google\_compute\_region\_instance\_group\_manager of the instance group. | diff --git a/modules/mig/metadata.display.yaml b/modules/mig/metadata.display.yaml index 17fddfc3..affbb014 100644 --- a/modules/mig/metadata.display.yaml +++ b/modules/mig/metadata.display.yaml @@ -67,7 +67,7 @@ spec: hostname: name: hostname title: Hostname - invisible: false + level: 1 instance_template: name: instance_template title: Instance Template @@ -80,9 +80,9 @@ spec: mig_name: name: mig_name title: Mig Name - invisible: false regexValidation: ^[a-z][a-z0-9-]{0,61}[a-z0-9]$ validation: Use lowercase letters, numbers, and hyphens. Start with a letter and end with letter/number. Must be 63 characters or fewer. + level: 1 mig_timeouts: name: mig_timeouts title: Mig Timeouts @@ -95,7 +95,7 @@ spec: project_id: name: project_id title: Project Id - invisible: false + level: 1 region: name: region title: Region @@ -114,7 +114,7 @@ spec: target_size: name: target_size title: Target Size - invisible: false + level: 1 update_policy: name: update_policy title: Update Policy diff --git a/modules/mig/metadata.yaml b/modules/mig/metadata.yaml index 28d56796..72505e25 100644 --- a/modules/mig/metadata.yaml +++ b/modules/mig/metadata.yaml @@ -286,6 +286,12 @@ spec: varType: map(string) defaultValue: {} outputs: + - name: apphub_workload_uri + description: Workload URI in CAIS style to be used by Apphub. + type: + - object + - workload_id: string + workload_uri: string - name: health_check_self_links description: All self_links of healthchecks created for the instance group. type: diff --git a/modules/mig/outputs.tf b/modules/mig/outputs.tf index 8b0fc1e7..d5aecf35 100644 --- a/modules/mig/outputs.tf +++ b/modules/mig/outputs.tf @@ -35,3 +35,11 @@ output "health_check_self_links" { description = "All self_links of healthchecks created for the instance group." value = local.healthchecks } + +output "apphub_workload_uri" { + value = { + workload_uri = "//compute.googleapis.com/projects${element(split("/projects", google_compute_region_instance_group_manager.mig.instance_group), 1)}" + workload_id = substr(join("-", [tostring(google_compute_region_instance_group_manager.mig.name), md5(tostring(google_compute_region_instance_group_manager.mig.self_link))]), 0, 63) + } + description = "Workload URI in CAIS style to be used by Apphub." +}