Open CRASH-Tech opened 2 years ago
So, all of the examples I've seen of "withParam" have involved the use of the {{item}} in arguments. Have you seen anything indicating that it can be used elsewhere? If not, I wonder if this should be an enhancement or bug?
So, all of the examples I've seen of "withParam" have involved the use of the {{item}} in arguments. Have you seen anything indicating that it can be used elsewhere? If not, I wonder if this should be an enhancement or bug?
Hello, of couse, this is my case:
I'm using two templates, for manual and auto deploy(because I can't use "if" statement inside manifest section :(( )
apiVersion: argoproj.io/v1alpha1
kind: ClusterWorkflowTemplate
metadata:
name: argocd-publish
spec:
templates:
- name: auto
inputs:
parameters:
- name: project
- name: app
- name: env
- name: values_file
- name: git_url
- name: git_ref
- name: cluster
- name: namespace
resource:
action: apply
successCondition: status.sync.status == Synced, status.health.status == Healthy
manifest: |
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
finalizers:
- resources-finalizer.argocd.argoproj.io
labels:
project: "{{ inputs.parameters.project }}"
name: "{{ inputs.parameters.project }}-{{ inputs.parameters.env }}-{{ inputs.parameters.app }}"
namespace: "{{ $.Release.Namespace }}"
spec:
destination:
name: "{{ inputs.parameters.cluster }}"
namespace: "{{ inputs.parameters.namespace }}"
project: "{{ inputs.parameters.project }}"
source:
path: .
plugin:
env:
- name: DEPLOY_NAMESPACE
value: "deploy-{{ inputs.parameters.project }}"
- name: DEPLOY_SECRET
value: "deploy-{{ inputs.parameters.project }}"
- name: WERF_ENV
value: "{{ inputs.parameters.env }}"
- name: "WERF_VALUES_{{ inputs.parameters.env }}"
value: "{{ inputs.parameters.values_file }}"
- name: WERF_RELEASE
value: "{{ inputs.parameters.env }}-{{ inputs.parameters.app }}"
name: werf
repoURL: "{{ inputs.parameters.git_url }}"
targetRevision: "{{ inputs.parameters.git_ref }}"
syncPolicy:
automated: {}
syncOptions:
- CreateNamespace=true
- name: manual
inputs:
parameters:
- name: project
- name: app
- name: env
- name: values_file
- name: git_url
- name: git_ref
- name: cluster
- name: namespace
resource:
action: apply
manifest: |
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
finalizers:
- resources-finalizer.argocd.argoproj.io
labels:
project: "{{ inputs.parameters.project }}"
name: "{{ inputs.parameters.project }}-{{ inputs.parameters.env }}-{{ inputs.parameters.app }}"
namespace: "{{ $.Release.Namespace }}"
spec:
destination:
name: "{{ inputs.parameters.cluster }}"
namespace: "{{ inputs.parameters.namespace }}"
project: "{{ inputs.parameters.project }}"
source:
path: .
plugin:
env:
- name: DEPLOY_NAMESPACE
value: "deploy-{{ inputs.parameters.project }}"
- name: DEPLOY_SECRET
value: "deploy-{{ inputs.parameters.project }}"
- name: WERF_ENV
value: "{{ inputs.parameters.env }}"
- name: "WERF_VALUES_{{ inputs.parameters.env }}"
value: "{{ inputs.parameters.values_file }}"
- name: WERF_RELEASE
value: "{{ inputs.parameters.env }}-{{ inputs.parameters.app }}"
name: werf
repoURL: "{{ inputs.parameters.git_url }}"
targetRevision: "{{ inputs.parameters.git_ref }}"
syncPolicy:
syncOptions:
- CreateNamespace=true
Next, inside webhook I send deploy strategy (auto for dev, manual for prod )
apiVersion: argoproj.io/v1alpha1
kind: ClusterWorkflowTemplate
metadata:
name: ci-pipeline-git-tag
spec:
entrypoint: ci-pipeline-git-tag
templates:
- name: ci-pipeline-git-tag
inputs:
parameters:
- name: project
- name: git_url
- name: git_ref
- name: git_tag
- name: app
dag:
tasks:
- name: get-envs
templateRef:
name: werf-get-envs
template: werf-get-envs
clusterScope: true
arguments:
parameters:
- name: project
value: "{{ inputs.parameters.project }}"
- name: gitUrl
value: "{{ inputs.parameters.git_url }}"
- name: gitRef
value: "{{ inputs.parameters.git_ref }}"
- name: publish-manual
dependencies:
- get-envs
when: "{{ item.syncPolicy }} == 'manual'"
withParam: "{{ tasks.get-envs.outputs.result }}"
templateRef:
name: argocd-publish
template: "manual"
clusterScope: true
arguments:
parameters:
- name: project
value: "{{ inputs.parameters.project }}"
- name: app
value: "{{ inputs.parameters.app }}"
- name: env
value: "{{ item.env }}"
- name: values_file
value: "{{ item.values_file }}"
- name: git_url
value: "{{ inputs.parameters.git_url }}"
- name: git_ref
value: "{{ inputs.parameters.git_ref }}"
- name: cluster
value: "{{ item.cluster }}"
- name: namespace
value: "{{ item.namespace }}"
- name: publish-auto
dependencies:
- get-envs
when: "{{ item.syncPolicy }} == 'auto'"
withParam: "{{ tasks.get-envs.outputs.result }}"
templateRef:
name: argocd-publish
template: "auto"
clusterScope: true
arguments:
parameters:
- name: project
value: "{{ inputs.parameters.project }}"
- name: app
value: "{{ inputs.parameters.app }}"
- name: env
value: "{{ item.env }}"
- name: values_file
value: "{{ item.values_file }}"
- name: git_url
value: "{{ inputs.parameters.git_url }}"
- name: git_ref
value: "{{ inputs.parameters.git_ref }}"
- name: cluster
value: "{{ item.cluster }}"
- name: namespace
value: "{{ item.namespace }}"
As you can see, I need to use two steps with "when" for auto and dev. It's looks weird. It would be cool if i could use just one step and set template name from webhook value. Like this:
- name: publish
dependencies:
- get-envs
withParam: "{{ tasks.get-envs.outputs.result }}"
templateRef:
name: argocd-publish
template: "{{ item.syncPolicy }}"
clusterScope: true
arguments:
parameters:
- name: project
value: "{{ inputs.parameters.project }}"
- name: app
value: "{{ inputs.parameters.app }}"
- name: env
value: "{{ item.env }}"
- name: values_file
value: "{{ item.values_file }}"
- name: git_url
value: "{{ inputs.parameters.git_url }}"
- name: git_ref
value: "{{ inputs.parameters.git_ref }}"
- name: cluster
value: "{{ item.cluster }}"
- name: namespace
value: "{{ item.namespace }}"
"{{ item.image }}"
can be only substituted in arguments.
@CRASH-Tech I changed this issue into enhancement. Do you like to contribute this feature?
"{{ item.image }}"
can be only substituted in arguments. @CRASH-Tech I changed this issue into enhancement. Do you like to contribute this feature?
No, I can't.
@sarabala1979 I'd be happy to contribute support for this feature. Can you assign me?
@sarabala1979 I'd be happy to contribute support for this feature. Can you assign me?
Thanks for volunteering! Just assigned you
Any news on this?
Any news on this?
@ibacalu sorry, I'm still working on it. If you need it urgently, please feel free to take over the issue
maybe you have a date when you plan to realize this feature? @cpendery
Hi @AndriySidliarskiy, a different contributor will be taking over this issue once it's prioritized
Checklist
* [X] Double-checked my configuration. * [X] Tested using the latest version. * [X] Used the Emissary executor. ## Summary I'm trying to use {{ item }} variable to set name of used tamplate, but seems {{ item }} renders after dag step There is an example: ``` apiVersion: argoproj.io/v1alpha1 kind: Workflow metadata: name: test spec: entrypoint: ci arguments: parameters: - name: os-list value: | [ { "image": "debian", "tag": "9.1" }, { "image": "debian", "tag": "8.9" }, { "image": "alpine", "tag": "3.6" }, { "image": "ubuntu", "tag": "17.10" } ] templates: - name: ci inputs: parameters: - name: os-list dag: tasks: - name: publish withParam: "{{inputs.parameters.os-list}}" templateRef: name: argocd-publish template: "{{ item.image }}" ``` and error: `templates.ci.tasks.publish template reference argocd-publish.{{ item.image }} not found` argo-workflows version: 3.3.8 ---Message from the maintainers:
Impacted by this bug? Give it a 👍. We prioritise the issues with the most 👍.