config generation: escape map keys with whitespace #35754
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR updates the config generation package so map keys with whitespace are escaped with quotes. This is already handled automatically for the normal attribute generation, and nested blocks are also escaped by default. This PR updates the nested attributes so the keys of nested maps are validated and escaped if necessary. It is only maps that have this problem, attributes in objects cannot contain whitespace and other types (lists, sets, tuples) do not render keys anyway.
The rendering package has this same problem, and so far we've not handled it perfectly but just well enough. We'll continue to do so here, but the code calls out we could modify the HCL library so it exposes the internal functions it uses to detect when escaping is necessary and share those between HCL and Terraform. But so far, we've not had any need to take this too seriously.
Fixes #35752
Target Release
1.9.x
Draft CHANGELOG entry
BUG FIXES