Skip to content

Instantly share code, notes, and snippets.

@westonplatter
Forked from foobarbecue/aggregate-artifacts.yaml
Last active August 21, 2020 18:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save westonplatter/229d0f87b1e982353554424f2be3fcf1 to your computer and use it in GitHub Desktop.
Save westonplatter/229d0f87b1e982353554424f2be3fcf1 to your computer and use it in GitHub Desktop.
An example of using parameters to loop through artifact paths
apiVersion: v1
kind: ConfigMap
metadata:
name: workflow-controller-configmap
namespace: default
data:
artifactRepository: |
archiveLogs: true
s3:
repoName: MyArtifactRepo
bucket: my-bucket
endpoint: minio:9000
insecure: true
accessKeySecret:
name: my-minio-cred
key: accesskey
secretKeySecret:
name: my-minio-cred
key: secretkey
keyFormat: tmp
---
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generatename: artifact-selection-
namespace: default
spec:
entrypoint: select-files-test
templates:
- name: select-files-test
dag:
tasks:
- name: make-list
template: make-list
- name: create-files
template: create-files
arguments:
parameters:
- name: prod-id
value: "{{item}}"
withParam: "{{tasks.make-list.outputs.result}}"
dependencies: [make-list]
- name: save-aggregate-stats
template: save-aggregate-stats
dependencies: [create-files]
- name: needs-file-and-stats
template: needs-file-and-stats
arguments:
parameters:
- name: prod-id
value: "{{item}}"
withParam: "{{tasks.make-list.outputs.result}}"
dependencies: [save-aggregate-stats]
- name: make-list
container:
image: alpine:3.7
command:
- echo
- '["M1103401840LE", "M1103401840RE", "M1105737674LE", "M1105737674RE"]'
- name: create-files
inputs:
parameters:
- name: prod-id
script:
image: alpine:3.7
command: [sh]
source: |
head -c 1000 < /dev/urandom > /tmp/{{inputs.parameters.prod-id}}.txt
outputs:
artifacts:
- name: test-file
path: /tmp/{{inputs.parameters.prod-id}}.txt
archive:
none: {}
- name: save-aggregate-stats
inputs:
artifacts:
- name: created-files
path: /tmp/
repoName: MyArtifactRepo
script:
image: alpine:3.7
command: [sh]
source: |
ls /tmp > /tmp/list.txt
outputs:
artifacts:
- name: filelist
path: /tmp/list.txt
archive:
none: {}
repoName: MyArtifactRepo
- name: needs-file-and-stats
inputs:
parameters:
- name: prod-id
artifacts:
- name: created-files
path: /tmp/{{inputs.parameters.prod-id}}.txt
repoName: MyArtifactRepo
script:
image: alpine:3.7
command: [sh]
source: |
echo /tmp/{{inputs.parameters.prod-id}}.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment