You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Pull Request
## Issue
FixesAzure#132
## Description
This pull request includes significant enhancements to the
`Write-TfvarsFile` function in the `Config-Helpers` module. The changes
improve the handling of different data types when writing configuration
values, ensuring that default values are used when necessary and that
the correct format is applied for lists, maps, and objects.
### Enhancements to `Write-TfvarsFile` function:
* **Improved Handling of List Data Types**:
- Added a check for empty or null values and applied default values or
an empty list (`[]`) as needed.
(`src/ALZ/Private/Config-Helpers/Write-TfvarsFile.ps1`)
* **Added Support for Map Data Types**:
- Introduced logic to handle `map(string)` data types, ensuring that
empty maps are represented as `{}` and non-empty maps are properly
formatted. (`src/ALZ/Private/Config-Helpers/Write-TfvarsFile.ps1`)
* **Added Support for List of Objects Data Types**:
- Implemented handling for `list(object)` data types, ensuring that
empty lists are represented as `[]` and non-empty lists are correctly
formatted with key-value pairs.
(`src/ALZ/Private/Config-Helpers/Write-TfvarsFile.ps1`)
## Tests
Test 1:
With this inputs.yaml:

and this variables.tf:

Will result in this .tfvars:

Test 2:
With the same variables.tf file from example 1 and inputs.yaml file
missing declarations for the complex types:

Note: Although the logic to use the default values exists, there is
currently an issue $configuration.PSObject.Properties where the
defaultvalue is always empty even when a default value exists. Currently
something I am looking into further.
## License
By submitting this pull request, I confirm that my contribution is made
under the terms of the projects associated license.
0 commit comments