pipelines/frontend/mock-backend/mock-conditional-template.yaml

138 lines
3.8 KiB
YAML

# Copyright 2018 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: pipeline-flip-coin-
spec:
arguments:
parameters: []
entrypoint: pipeline-flip-coin
serviceAccountName: pipeline-runner
templates:
- dag:
tasks:
- arguments:
parameters:
- name: flip-again-output
value: '{{tasks.flip-again-task.outputs.parameters.flip-again-output}}'
- name: flip-output
value: '{{inputs.parameters.flip-output}}'
name: condition-2-task
template: condition-2
dependencies:
- flip-again-task
when: '{{tasks.flip-again-task.outputs.parameters.flip-again-output}} == tails'
- arguments:
parameters:
- name: flip-output
value: '{{inputs.parameters.flip-output}}'
name: flip-again-task
template: flip-again
inputs:
parameters:
- name: flip-output
name: condition-1
- dag:
tasks:
- arguments:
parameters:
- name: flip-again-output
value: '{{inputs.parameters.flip-again-output}}'
- name: flip-output
value: '{{inputs.parameters.flip-output}}'
name: print1-task
template: print1
inputs:
parameters:
- name: flip-again-output
- name: flip-output
name: condition-2
- dag:
tasks:
- arguments:
parameters:
- name: flip-output
value: '{{inputs.parameters.flip-output}}'
name: print2-task
template: print2
inputs:
parameters:
- name: flip-output
name: condition-3
- container:
args:
- python -c "import random; result = 'heads' if random.randint(0,1) == 0 else
'tails'; print(result)" | tee /tmp/output
command:
- sh
- -c
image: python:alpine3.6
name: flip
outputs:
parameters:
- name: flip-output
valueFrom:
path: /tmp/output
- container:
args:
- python -c "import random; result = 'heads' if random.randint(0,1) == 0 else
'tails'; print(result)" | tee /tmp/output
command:
- sh
- -c
image: python:alpine3.6
name: flip-again
outputs:
parameters:
- name: flip-again-output
valueFrom:
path: /tmp/output
- dag:
tasks:
- arguments:
parameters:
- name: flip-output
value: '{{tasks.flip-task.outputs.parameters.flip-output}}'
name: condition-1-task
template: condition-1
dependencies:
- flip-task
when: '{{tasks.flip-task.outputs.parameters.flip-output}} == heads'
- arguments:
parameters:
- name: flip-output
value: '{{tasks.flip-task.outputs.parameters.flip-output}}'
name: condition-3-task
template: condition-3
dependencies:
- flip-task
when: '{{tasks.flip-task.outputs.parameters.flip-output}} == tails'
- name: flip-task
template: flip
name: pipeline-flip-coin
- container:
command:
- echo
- '"it was tail"'
image: alpine:3.6
name: print1
- container:
command:
- echo
- '"it was tail"'
image: alpine:3.6
name: print2