command/format: Correctly quote diff object keys#25443
command/format: Correctly quote diff object keys#25443
Conversation
When rendering a diff, we should quote object attribute names if the string representation is not a valid identifier. While this is not strictly necessary, it makes the diff output more closely resemble the configuration language, which is less confusing. This commit applies to both top-level schema attributes and any object value attributes. We use a simplistic "%q" Go format string to quote the strings, which is not strictly identical to HCL's quoting requirements, but is the pattern used elsewhere in HCL and Terraform.
Codecov Report
|
apparentlymart
left a comment
There was a problem hiding this comment.
This looks good to me! 🎉
I'm sure one day we'll refactor this a bit, cause we essentially "shipped the prototype" here for 0.12, but this seems like a good incremental fix to make the output less confusing, despite the fact that it was kinda awkward to implement in our current structure.
|
This approach conflicts with some other upcoming work on the plan renderer, which is higher priority, so I'm not going to merge it at this time. |
|
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
When rendering a diff, we should quote object attribute names if the string representation is not a valid identifier. While this is not strictly necessary, it makes the diff output more closely resemble the configuration language, which is less confusing.
This commit applies to both top-level schema attributes and any object value attributes. We use a simplistic
"%q"Go format string to quote the strings, which is not strictly identical to HCL's quoting requirements but is the pattern used elsewhere in HCL and Terraform.Fixes #21749