-
I need help with escaping in my Argo Workflow: - name: faith-tmpl
inputs:
parameters:
- name: run_name
- name: repo_name
- name: release_name
- name: username
- name: run_params
metadata:
labels:
argo-workflows-e2e: "{{inputs.parameters.run_name}}"
annotations:
cluster-autoscaler.kubernetes.io/safe-to-evict: "false"
vault.hashicorp.com/agent-inject: "true"
vault.hashicorp.com/agent-pre-populate-only: "true"
vault.hashicorp.com/agent-inject-secret-.env: "{{=sprig.fromJson(steps.composer.outputs.parameters.output).vault_ci_path}}"
vault.hashicorp.com/role: home-ci
vault.hashicorp.com/agent-inject-template-.env: |
{{- with secret "{{=sprig.fromJson(steps.composer.outputs.parameters.output).vault_ci_path}}" }}
{{- range $k, $v := .Data.data }}
export {{ $k }}={{ $v }}
{{- end }}
{{- end }} The {{- with secret "{{=sprig.fromJson(steps.composer.outputs.parameters.output).vault_ci_path}}" }} I tried a few things but none worked for me. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 7 replies
-
In general, it is good to list what you tried. For folks trying to help and for other users with similar problems.
In this case you're using Argo templating within Vault templating, which uses But Argo's templating is evaluated first, so the string needs to be interpretable by Argo and then output a valid Argo's expression engine is {{= `{{- with secret ` + sprig.fromJson(steps.composer.outputs.parameters.output).vault_ci_path + ` }}` }} The first That should work in isolation, but you may need to further escape the entire Also you might not need to use |
Beta Was this translation helpful? Give feedback.
-
Eventually, this worked: {{= "{"+"{- with secret \"" + fromJSON(inputs.parameters.run_params).vault_ci_path + "\" }"+"}" } At the end of the line I concatenated two curly brackets because Honestly this seems way to complicated, I might just pass this as a parameter and set the value in the template. |
Beta Was this translation helpful? Give feedback.
Eventually, this worked:
{{= "{"+"{- with secret \"" + fromJSON(inputs.parameters.run_params).vault_ci_path + "\" }"+"}" }
At the end of the line I concatenated two curly brackets because
}}
didn't work for some reason (also tried-}}
). Now it works without escaping the rest of the lines.Honestly this seems way to complicated, I might just pass this as a parameter and set the value in the template.
Also, thanks for the tip about not having to use sprig,
fromJSON
works as well :)Also also, thanks for the explanation about the templating engines at work here.