Reputation: 75
apiVersion: argoproj.io/v1alpha1
kind: Workflow
.
.
- name: mytemplate
steps:
- - name: mytask
templateRef:
name: ABCDworkflowtemplate
template: taskA
arguments:
parameters:
- name: mylist
value: [10,"some",false]
....................
apiVersion: argoproj.io/v1alpha1
kind: WorkflowTemplate
metadata:
name: ABCDworkflowtemplate
spec:
templates:
- name: taskA
inputs:
parameters:
- name: mylist
.
My question is how to use every element of this list {{input.parameters.?}}
? Help me with some reference. Thank you
Upvotes: 5
Views: 7254
Reputation: 22316
You didn't really specify what exactly you want to do with these values so i'll explain both ways to use this input.
withParam
", With this syntax a new task (pod) will be created for each of the items. templates:
- name: taskA
inputs:
parameters:
- name: mylist
steps:
- - name: doSomeWithItem
template: doSomeWithItem
arguments:
parameters:
- name: item
value: "{{item}}"
withParam: "{{inputs.parameters.mylist}}"
- name: doSomeWithItem
inputs:
parameters:
- name: item
container:
image: python:alpine3.6
command: [ python ]
source: |
print("{{inputs.parameters.item}}")
The other option is just to pass the entire array as a variable to the pod, and use custom logic based on needs:
templates:
- name: taskA
inputs:
parameters:
- name: mylist
steps:
- - name: doSomethingWithList
template: doSomethingWithList
arguments:
parameters:
- name: list
value: "{{inputs.parameters.mylist}}"
- name: doSomethingWithList
inputs:
parameters:
- name: list
container:
image: python:alpine3.6
command: [ python ]
source: |
if (list[2] == 'some'):
// do somehting
else if (list[0] == 10]:
// do something
Upvotes: 3