diff --git a/CHANGELOG.md b/CHANGELOG.md index 562ac10119..4a7f5c7e64 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ BUG FIXES: * Add timeouts to Graph requests in API ([#4723](https://github.com/microsoft/AzureTRE/issues/4723)) * Fix missing metastoreDomains for Databricks, which caused metastore outages for some domains ([#4779](https://github.com/microsoft/AzureTRE/issues/4779)) * Fix cost display duplication when user resource is deleted - UI incorrectly reused cost data for remaining resources ([#4783](https://github.com/microsoft/AzureTRE/issues/4783)) +* Fix type mismatch error where `{{ resource.parent.my_boolean_property }}` was returning string instead of the correct type ([#4813](https://github.com/microsoft/AzureTRE/issues/4813)) * Delete npm package lock file ([#4810](https://github.com/microsoft/AzureTRE/issues/4810)) COMPONENTS: diff --git a/api_app/_version.py b/api_app/_version.py index 545cb33740..e6e3369ba2 100644 --- a/api_app/_version.py +++ b/api_app/_version.py @@ -1 +1 @@ -__version__ = "0.25.12" +__version__ = "0.25.13" diff --git a/api_app/service_bus/substitutions.py b/api_app/service_bus/substitutions.py index edafbb536e..a0d6668b4e 100644 --- a/api_app/service_bus/substitutions.py +++ b/api_app/service_bus/substitutions.py @@ -151,6 +151,8 @@ def substitute_value(val: str, primary_resource_dict: dict, primary_parent_ws_di if isinstance(prop_to_get, dict) or isinstance(prop_to_get, list): return prop_to_get else: + if val == "{{" + t + "}}": + return prop_to_get val = val.replace("{{" + t + "}}", str(prop_to_get)) return val diff --git a/api_app/tests_ma/test_service_bus/test_substitutions.py b/api_app/tests_ma/test_service_bus/test_substitutions.py index f8f81ca318..f31eb21587 100644 --- a/api_app/tests_ma/test_service_bus/test_substitutions.py +++ b/api_app/tests_ma/test_service_bus/test_substitutions.py @@ -416,3 +416,28 @@ def test_substitution_array_replace_not_found( obj = substitute_properties(step, primary_resource, None, None, resource_to_update) assert len(obj["rule_collections"]) == 1 assert obj["rule_collections"][0]["name"] == "Object 1" + + +def test_substitution_boolean_preservation(primary_resource): + resource_dict = primary_resource.dict() + # Mock a boolean property in the resource dict + resource_dict["properties"]["isEnabled"] = True + resource_dict["properties"]["count"] = 42 + + # Test boolean preservation + val_to_sub = "{{ resource.properties.isEnabled }}" + val = substitute_value(val_to_sub, resource_dict, None, None) + assert val is True + assert isinstance(val, bool) + + # Test int preservation + val_to_sub = "{{ resource.properties.count }}" + val = substitute_value(val_to_sub, resource_dict, None, None) + assert val == 42 + assert isinstance(val, int) + + # Test string concatenation (should fallback to string) + val_to_sub = "Count is {{ resource.properties.count }}" + val = substitute_value(val_to_sub, resource_dict, None, None) + assert val == "Count is 42" + assert isinstance(val, str) diff --git a/docs/tre-templates/pipeline-templates/pipeline-schema.md b/docs/tre-templates/pipeline-templates/pipeline-schema.md index 7d0d291581..411e5f4302 100644 --- a/docs/tre-templates/pipeline-templates/pipeline-schema.md +++ b/docs/tre-templates/pipeline-templates/pipeline-schema.md @@ -31,6 +31,17 @@ It's possible to refer to properties from the primary resource (the resource tha The syntax is `{{ resource.propertyName }}`. For example: `"{{ resource.properties.display_name }}"`. +### Accessing Parent Resource Properties +It's also possible to access properties from the parent resources. This is useful when a resource needs information from its container (e.g. a user resource needing the workspace service's address space). + +| Resource Type | Available References | Description | +| --- | --- | --- | +| User Resource | `{{ resource.parent.properties... }}` | Properties of the **Workspace Service** | +| User Resource | `{{ resource.parent.parent.properties... }}` | Properties of the **Workspace** | +| Workspace Service | `{{ resource.parent.properties... }}` | Properties of the **Workspace** | +| Workspace | N/A | Workspaces do not have parents in this context | +| Shared Service | N/A | Shared Services do not have parents in this context | + Example pipeline in `template_schema.json`: The below example references 2 properties from the primary resource to be used in updating the firewall shared service. diff --git a/docs/tre-workspace-authors/authoring-workspace-templates.md b/docs/tre-workspace-authors/authoring-workspace-templates.md index 23614bb29f..163a2358bf 100644 --- a/docs/tre-workspace-authors/authoring-workspace-templates.md +++ b/docs/tre-workspace-authors/authoring-workspace-templates.md @@ -76,6 +76,10 @@ All the values for the required parameters will be provided by the deployment ru Any **custom parameters** are picked up by Azure TRE API and will be queried from the user deploying the workspace bundle. Custom parameters should also be defined in the `template_schema.json` file at the root of the bundle. This file follows the [JSON schema standard](http://json-schema.org/) and can be used by a user interface to generate a UI for the user to input the parameters. +### Template properties + +When authoring a `template_schema.json` file, you can reference properties from the resource being deployed, or its parent resources. For more information see [Pipeline Template Schema](../tre-templates/pipeline-templates/pipeline-schema.md#substituting-resource-property-values). + ### Output !!! todo @@ -109,7 +113,7 @@ The size of the `address_space` will default to `/24`, however other sizes can b The `address_space` allocation will only take place during the install phase of a deployment, as this is a breaking change to your template you should increment the major version of your template, this means a you must deploy a new resource instead of upgrading an existing one. -In your install pipeline you also need to include a workspace upgrade step for the workspace to update it's `address_spaces` property. +In your install and uninstall pipelines you also need to include a workspace upgrade step for the workspace to update it's `address_spaces` property. ```json "pipeline": {