Skip to content

Commit

Permalink
fix: issue with variable brackets inside any string in extra_vars (re…
Browse files Browse the repository at this point in the history
…dhat-cop#868)

* fix: issue with variable brackets inside any string in extra_vars

* misc: implement suggested change

* Update current_job_templates.j2

Add `multiline=True` to treat multiple lines

* Update current_workflow_job_templates.j2

Add `multiline=True` to treat multiple lines

---------

Co-authored-by: Przemyslaw Kalitowski <[email protected]>
Co-authored-by: Ivan Aragonés Muniesa <[email protected]>
  • Loading branch information
3 people committed Nov 22, 2024
1 parent a6f1ef9 commit 35a5f90
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
bugfixes:
- filetree_create export extra_vars with escaping any variable brackets
...
2 changes: 1 addition & 1 deletion roles/filetree_create/templates/current_job_templates.j2
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ controller_templates:
{% endif %}
{% if current_job_templates_asset_value.extra_vars and current_job_templates_asset_value.extra_vars | length > 3 %}
extra_vars:
{{ current_job_templates_asset_value.extra_vars | from_yaml | to_nice_yaml(indent=2) | indent(width=6, first=False) | replace("'{{", "!unsafe \'{{") }}
{{ current_job_templates_asset_value.extra_vars | from_yaml | to_nice_yaml(indent=2) | indent(width=6, first=False) | regex_replace('(^[^:]*): (.*){{', '\1: !unsafe \2{{', multiline=True)}}
{%- endif %}
job_tags: "{{ current_job_templates_asset_value.job_tags }}"
force_handlers: {{ current_job_templates_asset_value.force_handlers | bool | lower }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ controller_workflows:
webhook_service: "{{ current_workflow_job_templates_asset_value.webhook_service }}"
{% if current_workflow_job_templates_asset_value.extra_vars and current_workflow_job_templates_asset_value.extra_vars | length > 3 %}
extra_vars:
{{ current_workflow_job_templates_asset_value.extra_vars | from_yaml | to_nice_yaml(indent=2) | indent(width=6, first=False) | replace("'{{", "!unsafe \'{{") }}
{{ current_workflow_job_templates_asset_value.extra_vars | from_yaml | to_nice_yaml(indent=2) | indent(width=6, first=False) | regex_replace('(^[^:]*): (.*){{', '\1: !unsafe \2{{', multiline=True) }}
{%- endif %}
{% if query_labels | length > 0 %}
labels:
Expand Down

0 comments on commit 35a5f90

Please sign in to comment.