-
Notifications
You must be signed in to change notification settings - Fork 42
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
Ensure replacement values are properly quoted when necessary #109
Comments
Can you use The given fix will always make the value a string, but we often use it for port values which are integers. |
Unfortunately |
This is a thorny problem, expanding the variables before merging would enable one to ensure they are quoted as suggested above, but leads to other issues such as environment variables in comments being expanded as well. To get around that specific issue the package could serialize and then deserialize all objects with the In our case, I was able to just change the problematic value to a new value which did not need to be quoted. I'll leave the issue open just in case others run into the same problem. It would also be helpful if the package returned custom errors which allowed users to access the merged YAML file as the line numbers in the error messages are for the merged file and therefore make it difficult to track down which specific line is causing a given issue. |
Can you quote the value in the environment variable itself? One odd thing about the environment variable replacement is that you can technically add a full-blown object through the environment variable, which is possible because there's no re-escaping. It's an undocumented accidental feature, but it can come in handy, but that also means you can treat the environment variable as a serialized YAML value itself. |
I could, but it's less overhead for me to just replace the value. I control the value of the variable (it's created in Terraform and then stored as a secret in Kubernetes) so I think it will be more maintainable to just replace it and ensure it doesn't have any problematic characters moving forward than have to remember that the value has quotes. And I agree, I like that you can pass in an entire object through an environment variable. It would just be nice if the quotes around the variables weren't lost so you could control whether the variable should be interpreted as a string or not. |
YAML requires that strings which contain characters that conflict with YAML syntax elements must be quoted in order to be parsed properly. For example, YAML does not allow unquoted strings to begin with the
@
character so any string that begins with this character must be quoted. TheexpandTransformer
, however, does not currently check if a replacement value needs to be quoted and will produce invalid YAML if it's lookup function returns a value that must be quoted. This problem is reproduced in the following program:The output of this program is:
The issue is that the YAML template
is converted to the following YAML source
but in order for this source to be valid YAML it should be
The text was updated successfully, but these errors were encountered: