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
(BTW, this same logic is also present in workspace_controller_outputs.go)
Because of the trimming of the ", the string output is not a valid JSON string and cannot be unmarshaled back to a string.
But even if it would be a valid JSON string, it still makes working with string outputs difficult, as you always have to add some logic before using the string. Especially in the case where you are mounting the ConfigMap key to a file, it would be nice to have the actual string value so the file contains actual newlines (and other special characters) and you can just read the file directly without worrying about the format.
For a real world example; We encountered this while creating an OpenSSH key and wanting to mount the key as a file so our application can use it. It broke while moving from the Flux Terraform Controller to this operator. (We have worked around this issue for now by replacing \n with actual newlines when reading the file).
References
N/A
Community Note
Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.
Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request.
If you are interested in working on this issue or have submitted a pull request, please leave a comment.
The text was updated successfully, but these errors were encountered:
Before marshaling the string that TFC returns looks like this: "hello\nworld", after marshaling "\"hello\\nworld\"".
I have prepared a fix that will introduce better handling for different types that Terraform supports. With this fix the above outputs looks like this in a config map:
Operator Version, Kind and Kubernetes Version
YAML Manifest File
Output Log
N/A
Output of relevant
kubectl
commandsN/A
Steps To Reproduce
Expected Behavior
I expect to have the actual string value in the ConfigMap, so with actual newline characters.
Actual Behavior
The string in the output contains
\n
as the actual characters instead of a newline.Additional Context
According to this piece of code, all output is parsed to JSON, which makes sense for objects as output:
https://github.com/hashicorp/terraform-cloud-operator/blob/082ac4aa99b593b5b79ccde99abc0ae0de48dbc0/controllers/module_controller_outputs.go#L80C2-L92C3
(BTW, this same logic is also present in
workspace_controller_outputs.go
)Because of the trimming of the
"
, the string output is not a valid JSON string and cannot be unmarshaled back to a string.But even if it would be a valid JSON string, it still makes working with string outputs difficult, as you always have to add some logic before using the string. Especially in the case where you are mounting the ConfigMap key to a file, it would be nice to have the actual string value so the file contains actual newlines (and other special characters) and you can just read the file directly without worrying about the format.
For a real world example; We encountered this while creating an OpenSSH key and wanting to mount the key as a file so our application can use it. It broke while moving from the Flux Terraform Controller to this operator. (We have worked around this issue for now by replacing
\n
with actual newlines when reading the file).References
N/A
Community Note
The text was updated successfully, but these errors were encountered: