3

Conditional checking in Argo workflow

 1 year ago
source link: https://donghao.org/2022/08/19/conditional-checking-in-argo-workflow/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Conditional checking in Argo workflow

My company has been using Argo for executing workflow for more than three years. I knew every step in the Argo workflow could be controlled by when expression, like this:

apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  generateName: example-
spec:
  entrypoint: first-step
  arguments:
  - parameters:
    - - name: 'COLOR',
        value: std.extVar('COLOR'),
  templates:
  - name: first-stage
    steps:
    # flip a coin
    - - name: first-step
        template: step-first
        when: '{{workflow.parameters.COLOR}} == red',
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  generateName: example-
spec:
  entrypoint: first-step
  arguments:
  - parameters:
    - - name: 'COLOR',
        value: std.extVar('COLOR'),
  templates:
  - name: first-stage
    steps:
    # flip a coin
    - - name: first-step
        template: step-first
        when: '{{workflow.parameters.COLOR}} == red',

What if I want to check more than one condition? Just use “&&” as “and”, “||” as “or”:

...
  - name: first-stage
    steps:
    # flip a coin
    - - name: first-step
        template: step-first
        when: '{{workflow.parameters.COLOR}} == red || {{workflow.parameters.COLOR}} == blue',
...
  - name: first-stage
    steps:
    # flip a coin
    - - name: first-step
        template: step-first
        when: '{{workflow.parameters.COLOR}} == red || {{workflow.parameters.COLOR}} == blue',

Reference

Related Posts

August 19, 2022 - 3:54 RobinDong develop
Argo
Leave a comment

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Comment *

Name *

Email *

Website

Save my name, email, and website in this browser for the next time I comment.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK