Skip to content

fix: Bug-132 #137

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 23, 2024
Merged

fix: Bug-132 #137

merged 2 commits into from
Aug 23, 2024

Conversation

oZakari
Copy link
Contributor

@oZakari oZakari commented Aug 23, 2024

Pull Request

Issue

Fixes #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:
image
and this variables.tf:
image

Will result in this .tfvars:
image

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

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.

@oZakari oZakari requested a review from matt-FFFFFF August 23, 2024 02:35
@oZakari oZakari added Type: Bug 🪲 Something isn't working Area: Terraform Accelerator 👽 Issues / PR's related to Terraform Accelerator labels Aug 23, 2024
@matt-FFFFFF
Copy link
Member

@oZakari

Thanks so much for this! Excellent work

@oZakari oZakari merged commit 6c37952 into Azure:main Aug 23, 2024
3 checks passed
@oZakari oZakari deleted the bug-132 branch August 23, 2024 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: Terraform Accelerator 👽 Issues / PR's related to Terraform Accelerator Type: Bug 🪲 Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Starter module non-primitive type variable populated as a string
2 participants