Update to fix valueFrom in kubevip args - #405
Conversation
Fixes: - whitespace generation that creates poorly formatted files. - valueFrom should not be quoted as it generates broken files.
|
Fixes #406 |
MonolithProjects
left a comment
There was a problem hiding this comment.
You are right about the issue. But your fix will end up as a single line in the output file. Better would be something like:
{% for item in rke2_kubevip_args %}
- name: {{ item.param }}
{% if item.value is defined %}
value: {{ item.value | string | to_json }}
{% endif %}
{% if item.valueFrom is defined %}
valueFrom: {{ item.valueFrom | to_json }}
{% endif %}
{% endfor %}Dropping the - from {%- if %} keeps the newline after name: intact, so value/valueFrom land on their own line instead of collapsing onto the name: line.
If you don't have a cluster to test, you can always use an Ansible template tester like for example https://ansible.sivel.net/test/
Update values to fix whitespace and formatting issues with jijna rendering
|
@MonolithProjects I've done a bit of a refactor here to make the output all nice and prettified. I tested it with the template tester but will also rebuild my cluster using it once it's released. I don't know how to test my updates before that, if you can link me a doc on how to do that, I'm happy to. |
MonolithProjects
left a comment
There was a problem hiding this comment.
Last commit introduces multiple issues (you left trailing quotes on several lines and also reverting the #403 fix...). Please do not introduce additional changes in this PR. Lets keep it small and keep only the valueForm fix. You can open separate PR if you see additional problems.
|
Sorry about that. Bad commit on my part. |
|
I ended up doing both. The final commit is what you've asked for, a small bugfix targeting only the reported issue. I also have a commit with the other changes that were from a missing save from when I was working too quickly. Sorry about that again. I can open a new PR with those changes, and as for why, we're generating yaml, not json, and to_json will produce incorrect results when not rendering strings but that can be a problem for another day, since those should always be strings. |
Sure, you can open a new PR for those. Thanks for your contribution! |
Fixes:
Description
When generating the blob from the template, the resulting file is currently generated in a poorly formatted way. Additionally, valueFrom is quoted in multiple places which results in a file that cannot be installed into the cluster.
Type of change
How Has This Been Tested?
It isn't. I don't know how to test this without creating a new release. It should be easy to test by applying with any kubevip args.