Skip to content

Commit edf0770

Browse files
authored
credentials when using secrets_as_variables: (#140)
* credentials when using secrets_as_variables: - also replace other non valid characters with underscore - add a default to '$encrypted$' if variable is not set * typo
1 parent 48341c7 commit edf0770

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

roles/filetree_create/templates/controller_credentials.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ controller_credentials:
2020
{% if show_encrypted is defined and show_encrypted %}
2121
{{ input.key }}: {{ input.value }}
2222
{% elif secrets_as_variables is defined and secrets_as_variables %}
23-
{{ input.key }}: {{ input.value | replace("$encrypted$", "\"{{ " + secrets_as_variables_prefix + "_controller_credentials_" + (current_credentials_asset_value.name | replace(' ', '_') | lower) + "_" + (input.key | replace(' ', '_') | lower) + " }}\"") }}
23+
{{ input.key }}: {{ input.value | replace("$encrypted$", "\"{{ " + secrets_as_variables_prefix + "_controller_credentials_" + (current_credentials_asset_value.name | lower | regex_replace('[^a-z0-9]','_')) + "_" + (input.key | lower | regex_replace('[^a-z0-9]', '_')) + " | default('$encrypted$') }}\"") }}
2424
{% else %}
2525
{{ input.key }}: {{ input.value | replace("$encrypted$", "\'\'") }}
2626
{% endif %}

roles/filetree_create/templates/eda_credentials.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ eda_credentials:
2323
{% if show_encrypted is defined and show_encrypted %}
2424
{{ input.key }}: {{ input.value }}
2525
{% elif secrets_as_variables is defined and secrets_as_variables %}
26-
{{ input.key }}: {{ input.value | replace("$encrypted$", "\"{{ " + secrets_as_variables_prefix + "_eda_credentials_" + (eda_credential.name | replace(' ', '_') | lower) + "_" + (input.key | replace(' ', '_') | lower) + " }}\"") }}
26+
{{ input.key }}: {{ input.value | replace("$encrypted$", "\"{{ " + secrets_as_variables_prefix + "_eda_credentials_" + (eda_credential.name | lower | regex_replace('[^a-z0-9]','_')) + "_" + (input.key | lower | regex_replace('[^a-z0-9]','_')) + " | default('$encrypted$') }}\"") }}
2727
{% else %}
2828
{{ input.key }}: {{ input.value | replace("$encrypted$", "\'\'") }}
2929
{% endif %}

0 commit comments

Comments
 (0)