Skip to content

Commit

Permalink
Improve example yamls
Browse files Browse the repository at this point in the history
  • Loading branch information
jessesuen committed Nov 2, 2017
1 parent f83b262 commit d983874
Show file tree
Hide file tree
Showing 11 changed files with 115 additions and 68 deletions.
11 changes: 5 additions & 6 deletions examples/artifact-passing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,16 @@ metadata:
spec:
entrypoint: artifact-example
templates:
-
name: artifact-example
- name: artifact-example
steps:
- COWSAY:
template: cowsay
- PRINT:
template: print-message
arguments:
artifacts.MESSAGE: "{{steps.COWSAY.outputs.artifacts.MESSAGE}}"
-
name: cowsay

- name: cowsay
container:
image: docker/whalesay:latest
command: [sh, -c]
Expand All @@ -24,8 +23,8 @@ spec:
artifacts:
MESSAGE:
path: /tmp/hello_world.txt
-
name: print-message

- name: print-message
inputs:
artifacts:
MESSAGE:
Expand Down
34 changes: 20 additions & 14 deletions examples/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,34 +13,40 @@ spec:
requests:
storage: 1Gi
templates:
-
name: ci-example
- name: ci-example
steps:
- BUILD:
template: build
- TEST:
template: test
-
name: build

- name: build
inputs:
artifacts:
- name: CODE
path: /src
git:
url: https://github.com/argoproj/argo.git
# NOTE: we need to handle overlapping input artifacts with volume mounts.
# In the case where input artifacts are desired to be placed in a sub-directory
# of a volume mount, the executor should place the artifact in the volume, as
# opposed to the artifacts volume
CODE:
path: /go/src/github.com/golang/example
git:
url: https://github.com/golang/example.git
container:
image: golang:1.8
command: [sh, -c]
args: ["cd /src && dep ensure && make"]
args: ["
cd /go/src/github.com/golang/example/hello &&
go build -v .
"]
volumeMounts:
- name: workdir
mountPath: /src
-
name: test
mountPath: /go
- name: test
container:
image: debian:9.1
command: [sh, -c]
args: ["/src/dist/argo verison"]
args: ["/go/src/github.com/golang/example/hello/hello ; sleep 9999; echo done"]
volumeMounts:
- name: workdir
mountPath: /src
mountPath: /go
13 changes: 6 additions & 7 deletions examples/coinflip.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ metadata:
spec:
entrypoint: coinflip
templates:
-
name: coinflip
- name: coinflip
steps:
- FLIP-COIN:
template: flip-coin
Expand All @@ -16,17 +15,17 @@ spec:
TAILS:
template: tails
when: "{{steps.FLIP-COIN.outputs.result}} == tails"
-
name: flip-coin

- name: flip-coin
script:
image: python:3.6
command: [python]
source: |
import random
result = "heads" if random.randint(0,1) == 0 else "tails"
print(result)
-
name: heads
- name: heads
container:
image: docker/whalesay:latest
command: [sh, -c]
Expand All @@ -36,4 +35,4 @@ spec:
container:
image: docker/whalesay:latest
command: [sh, -c]
args: ["echo \"it was tails\""]
args: ["echo \"it was tails\""]
7 changes: 3 additions & 4 deletions examples/conditionals.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,16 @@ spec:
arguments:
parameters.DO-PRINT: "false"
templates:
-
name: conditional-example
- name: conditional-example
inputs:
parameters:
DO-PRINT:
steps:
- PRINT-HELLO:
template: cowsay
when: "{{inputs.parameters.DO-PRINT}} == true"
-
name: cowsay

- name: cowsay
container:
image: docker/whalesay:latest
command: [sh, -c]
Expand Down
28 changes: 15 additions & 13 deletions examples/loops-maps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,24 @@ metadata:
spec:
entrypoint: loop-map-example
templates:
-
name: loop-map-example
- name: loop-map-example
steps:
- COWSAY:
template: cowsay
- PRINT-OS:
template: cat-os-release
arguments:
parameters.MESSAGE: "{{item.adjective}} {{item.noun}}"
parameters.IMAGE: "{{item.image}}"
parameters.TAG: "{{item.tag}}"
withItems:
- { adjective: 'friendly', noun: 'dog' }
- { adjective: 'sneaky', noun: 'cat' }
-
name: cowsay
- { image: 'debian', tag: '9.1' }
- { image: 'debian', tag: '8.9' }
- { image: 'alpine', tag: '3.6' }

- name: cat-os-release
inputs:
parameters:
MESSAGE:
IMAGE:
TAG:
container:
image: docker/whalesay:latest
command: [cowsay]
args: ["{{inputs.parameters.MESSAGE}}"]
image: "{{inputs.parameters.IMAGE}}:{{inputs.parameters.TAG}}"
command: [cat]
args: [/etc/os-release]
7 changes: 3 additions & 4 deletions examples/loops.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ metadata:
spec:
entrypoint: loop-example
templates:
-
name: loop-example
- name: loop-example
steps:
- COWSAY:
template: cowsay
Expand All @@ -15,8 +14,8 @@ spec:
withItems:
- hello world
- goodbye world
-
name: cowsay

- name: cowsay
inputs:
parameters:
MESSAGE:
Expand Down
45 changes: 45 additions & 0 deletions examples/nested-workflow.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
apiVersion: argoproj.io/v1
kind: Workflow
metadata:
generateName: argo-wf-
spec:
entrypoint: nested-workflow-example
templates:
- name: nested-workflow-example
steps:
- COWSAY:
template: cowsay
- NESTED:
template: nested-wf
arguments:
artifacts.MESSAGE: "{{steps.COWSAY.outputs.artifacts.MESSAGE}}"

- name: cowsay
container:
image: docker/whalesay:latest
command: [sh, -c]
args: ["cowsay hello world | tee /tmp/hello_world.txt"]
outputs:
artifacts:
MESSAGE:
path: /tmp/hello_world.txt

- name: nested-wf
inputs:
artifacts:
MESSAGE:
steps:
- PRINT:
template: print-message
arguments:
artifacts.MESSAGE: "{{inputs.artifacts.MESSAGE}}"

- name: print-message
inputs:
artifacts:
MESSAGE:
path: /tmp/message
container:
image: alpine:latest
command: [sh, -c]
args: ["cat /tmp/message; sleep 999999"]
11 changes: 5 additions & 6 deletions examples/scripts-python.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,25 @@ metadata:
spec:
entrypoint: python-script-example
templates:
-
name: python-script-example
- name: python-script-example
steps:
- GENERATE:
template: gen-random-int
- PRINT:
template: print-message
arguments:
parameters.MESSAGE: "{{steps.GENERATE.outputs.result}}"
-
name: gen-random-int

- name: gen-random-int
script:
image: python:3.6
command: [python3]
source: |
import random
i = random.randint(1, 100)
print(i)
-
name: print-message
- name: print-message
inputs:
parameters:
MESSAGE:
Expand Down
11 changes: 5 additions & 6 deletions examples/volumes.yaml → examples/volumes-existing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,23 @@ spec:
persistentVolumeClaim:
claimName: workdir
templates:
-
name: volume-example
- name: volume-example
steps:
- COWSAY:
template: cowsay
- PRINT:
template: print-message
-
name: cowsay

- name: cowsay
container:
image: docker/whalesay:latest
command: [sh, -c]
args: ["echo generating message in volume; cowsay hello world | tee /mnt/vol/hello_world.txt"]
volumeMounts:
- name: workdir
mountPath: /mnt/vol
-
name: print-message

- name: print-message
container:
image: alpine:latest
command: [sh, -c]
Expand Down
12 changes: 5 additions & 7 deletions examples/volumes-pvc.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

apiVersion: argoproj.io/v1
kind: Workflow
metadata:
Expand All @@ -14,24 +13,23 @@ spec:
requests:
storage: 1Gi
templates:
-
name: volume-pvc-example
- name: volume-pvc-example
steps:
- COWSAY:
template: cowsay
- PRINT:
template: print-message
-
name: cowsay

- name: cowsay
container:
image: docker/whalesay:latest
command: [sh, -c]
args: ["echo generating message in volume; cowsay hello world | tee /mnt/vol/hello_world.txt"]
volumeMounts:
- name: workdir
mountPath: /mnt/vol
-
name: print-message

- name: print-message
container:
image: alpine:latest
command: [sh, -c]
Expand Down
4 changes: 3 additions & 1 deletion workflow/controller/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,9 @@ func (woc *wfOperationCtx) executeContainer(nodeName string, tmpl *wfv1.Template
}

func (woc *wfOperationCtx) executeSteps(nodeName string, steps []map[string]wfv1.WorkflowStep) error {
var scope wfScope
scope := wfScope{
scope: make(map[string]interface{}),
}
for i, stepGroup := range steps {
sgNodeName := fmt.Sprintf("%s[%d]", nodeName, i)
err := woc.executeStepGroup(stepGroup, sgNodeName, &scope)
Expand Down

0 comments on commit d983874

Please sign in to comment.