diff --git a/modules/meshstack/noop/buildingblock/README.md b/modules/meshstack/noop/buildingblock/README.md index eb9e9c60..e8829278 100644 --- a/modules/meshstack/noop/buildingblock/README.md +++ b/modules/meshstack/noop/buildingblock/README.md @@ -26,6 +26,7 @@ Use it to: | `sensitive_yaml` | `CODE` | `STATIC` (sensitive) | Encrypted YAML/JSON value, decrypted at runtime | | `static` | `STRING` | `STATIC` | A platform-engineer-defined string constant | | `static_code` | `CODE` | `STATIC` | A platform-engineer-defined map | +| `tag_value` | `CODE` | `TAG` | Value of a meshStack tag, read from the target object rather than typed in by a user | | `flag` | `BOOLEAN` | `USER_INPUT` | Boolean flag chosen by the user | | `num` | `INTEGER` | `USER_INPUT` | Integer chosen by the user | | `text` | `STRING` | `USER_INPUT` | Free-text string from the user | @@ -78,6 +79,7 @@ No modules. | [single\_select](#input\_single\_select) | n/a | `string` | n/a | yes | | [static](#input\_static) | n/a | `string` | n/a | yes | | [static\_code](#input\_static\_code) | n/a | `map(string)` | n/a | yes | +| [tag\_value](#input\_tag\_value) | n/a | `list(string)` | n/a | yes | | [text](#input\_text) | n/a | `string` | n/a | yes | | [user\_permissions](#input\_user\_permissions) | n/a |
list(object({
meshIdentifier = string
username = string
firstName = string
lastName = string
email = string
euid = string
roles = list(string)
})) | n/a | yes |
| [user\_permissions\_json](#input\_user\_permissions\_json) | n/a | `string` | n/a | yes |
@@ -102,6 +104,7 @@ No modules.
| [static](#output\_static) | n/a |
| [static\_code](#output\_static\_code) | n/a |
| [summary](#output\_summary) | n/a |
+| [tag\_value](#output\_tag\_value) | n/a |
| [text](#output\_text) | n/a |
| [user\_permissions](#output\_user\_permissions) | n/a |
| [user\_permissions\_json](#output\_user\_permissions\_json) | n/a |
diff --git a/modules/meshstack/noop/buildingblock/outputs.tf b/modules/meshstack/noop/buildingblock/outputs.tf
index e606ea2b..5a49de02 100644
--- a/modules/meshstack/noop/buildingblock/outputs.tf
+++ b/modules/meshstack/noop/buildingblock/outputs.tf
@@ -27,6 +27,10 @@ output "static_code" {
value = var.static_code
}
+output "tag_value" {
+ value = var.tag_value
+}
+
output "flag" {
value = var.flag
}
@@ -113,6 +117,7 @@ output "debug_input_variables_json" {
multi_select_json = var.multi_select_json
static = var.static
static_code = var.static_code
+ tag_value = var.tag_value
user_permissions = var.user_permissions
user_permissions_json = var.user_permissions_json
})
diff --git a/modules/meshstack/noop/buildingblock/variables.tf b/modules/meshstack/noop/buildingblock/variables.tf
index 5c562a81..d403ca46 100644
--- a/modules/meshstack/noop/buildingblock/variables.tf
+++ b/modules/meshstack/noop/buildingblock/variables.tf
@@ -27,6 +27,12 @@ variable "static_code" {
type = map(string)
}
+variable "tag_value" {
+ # meshStack sends a TAG input as a JSON array of strings; a tag with no value resolves to null.
+ type = list(string)
+ nullable = true
+}
+
variable "flag" {
type = bool
}
diff --git a/modules/meshstack/noop/e2e/main.tf b/modules/meshstack/noop/e2e/main.tf
index d27b1d0d..43ae66e1 100644
--- a/modules/meshstack/noop/e2e/main.tf
+++ b/modules/meshstack/noop/e2e/main.tf
@@ -8,6 +8,30 @@ variable "test_context" {
nullable = false
}
+# A tag input reads its value from an existing meshStack tag, so the e2e test provisions its own
+# tag definition and sets it on the test workspace to exercise the input end-to-end. It cannot be
+# destroyed while the building block definition below reads it, so referencing its `spec.key` from
+# the module's `tag_key` input (and the workspace tag depending on the definition) gets destroy
+# order right on its own.
+resource "meshstack_tag_definition" "noop_e2e" {
+ spec = {
+ target_kind = "meshWorkspace"
+ key = "noop-e2e-tag-${var.test_context.name_suffix}"
+ display_name = "NoOp E2E Tag"
+ value_type = { string = {} }
+ }
+}
+
+resource "meshstack_workspace_tag" "noop_e2e" {
+ metadata = {
+ workspace_identifier = var.test_context.workspace
+ key = meshstack_tag_definition.noop_e2e.spec.key
+ }
+ spec = {
+ values = ["e2e-tag-value"]
+ }
+}
+
module "noop" {
source = "../"
meshstack = {
@@ -18,9 +42,14 @@ module "noop" {
git_ref = var.test_context.hub_git_ref
bbd_draft = true
}
+ tag_object = "WORKSPACE"
+ tag_key = meshstack_tag_definition.noop_e2e.spec.key
}
resource "meshstack_building_block" "this" {
+ # ensures the tag has a value before the building block run reads it
+ depends_on = [meshstack_workspace_tag.noop_e2e]
+
wait_for_completion = true
spec = {
building_block_definition_version_ref = module.noop.building_block_definition.version_ref
@@ -40,6 +69,7 @@ resource "meshstack_building_block" "this" {
single_select = { value = jsonencode("single1") }
multi_select = { value = jsonencode(["multi1", "multi2"]) }
multi_select_json = { value = jsonencode(["multi2", "multi1"]) }
+ # tag_value =