[[2021-06-17_Thu]] #argo Argoは、withItemsでループできる。 ```yaml spec: entrypoint: loop-example templates: - name: loop-example steps: - - name: print-message template: whalesay arguments: parameters: - name: message value: "{{item}}" withItems: - hello world - goodbye world ``` [argo-workflows/loops.yaml at master · argoproj/argo-workflows · GitHub](https://github.com/argoproj/argo-workflows/blob/master/examples/loops.yaml) withItems以外にも似たような設定項目がある。 - withItems: stepを並列実行stepに分解 - withParam: JSON リストを渡す? - withSequence: stepをnumeric sequenceへ withSequenceの使い方は [argo-workflows/loops-sequence.yaml at master · argoproj/argo-workflows · GitHub](https://github.com/argoproj/argo-workflows/blob/master/examples/loops-sequence.yaml) #### templateの出力をもとにループ ```yaml templates: - name: loop-param-result-example steps: - - name: generate template: gen-number-list # Iterate over the list of numbers generated by the generate step above - - name: sleep template: sleep-n-sec arguments: parameters: - name: seconds value: "{{item}}" withParam: "{{steps.generate.outputs.result}}" # Generate a list of numbers in JSON format - name: gen-number-list script: image: python:alpine3.6 command: [python] source: | import json import sys json.dump([i for i in range(20, 31)], sys.stdout) ```