-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: enable when expressions to use expr; add new json variables to avoid expr conflicts #9761
Merged
Merged
Changes from 3 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
84cd418
fix: enable when expressions to use expr; add new json variables to a…
juliev0 2ddc6b2
fix: empty commit
juliev0 8258a15
fix: accidental removal of code
juliev0 719bfbc
fix: show example which requires the use of dashes
juliev0 ec1bc67
docs: new variables exposed in the documentation
juliev0 8fed36e
fix: empty commit
juliev0 8d9515f
fix: empty commit
juliev0 30ac1a0
fix: merge conflict
juliev0 9f8978e
fix: empty commit
juliev0 4e1a948
fix: merge conflict
juliev0 b9ebb06
fix: empty commit
juliev0 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,41 @@ | ||
# Conditionals provide a way to affect the control flow of a | ||
# workflow at runtime, depending on parameters. In this example | ||
# the 'print-hello' template may or may not be executed depending | ||
# on the input parameter, 'should-print'. When submitted with: | ||
# the 'printHello' template may or may not be executed depending | ||
# on the input parameter, 'shouldPrint'. When submitted with: | ||
# argo submit examples/conditionals.yaml | ||
# the step will be skipped since 'should-print' will evaluate false. | ||
# the step will be skipped since 'shouldPrint' will evaluate false. | ||
# When submitted with: | ||
# argo submit examples/conditionals.yaml -p should-print=true | ||
# the step will be executed since 'should-print' will evaluate true. | ||
# argo submit examples/conditionals.yaml -p shouldPrint=true | ||
# the step will be executed since 'shouldPrint' will evaluate true. | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: Workflow | ||
metadata: | ||
generateName: conditional- | ||
spec: | ||
entrypoint: conditional-example | ||
entrypoint: conditionalExample | ||
arguments: | ||
parameters: | ||
- name: should-print | ||
value: "false" | ||
- name: shouldPrint | ||
value: "true" | ||
|
||
templates: | ||
- name: conditional-example | ||
- name: conditionalExample | ||
inputs: | ||
parameters: | ||
- name: should-print | ||
- name: shouldPrint | ||
steps: | ||
- - name: print-hello | ||
template: whalesay | ||
when: "{{inputs.parameters.should-print}} == true" | ||
- - name: printHello-govaluate | ||
template: argosay | ||
when: "{{inputs.parameters.shouldPrint}} == true" # govaluate form | ||
- name: printHello-expr | ||
template: argosay | ||
when: "{{= inputs.parameters.shouldPrint == 'true'}}" # expr form | ||
- name: printHello-expr-json | ||
template: argosay | ||
when: "{{=jsonpath(workflow.parameters.json, '$[0].value') == 'true'}}" # expr form | ||
|
||
- name: whalesay | ||
- name: argosay | ||
container: | ||
image: docker/whalesay:latest | ||
image: argoproj/argosay:v1 | ||
command: [sh, -c] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. had to change the whalesay image to argosay image since apparently whalesay isn't supposed to be used for e2e tests |
||
args: ["cowsay hello"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
apiVersion: argoproj.io/v1alpha1 | ||
kind: Workflow | ||
|
||
metadata: | ||
generateName: json-variables- | ||
|
||
labels: | ||
myLabel: myLabelValue | ||
annotations: | ||
myAnnotation: myAnnotationValue | ||
spec: | ||
entrypoint: argosay1 | ||
arguments: | ||
parameters: | ||
- name: myParam | ||
value: myParamValue | ||
|
||
templates: | ||
- name: argosay1 | ||
container: | ||
image: argoproj/argosay:v1 | ||
command: [echo] | ||
args: | ||
- "{{=jsonpath(workflow.labels.json, '$.myLabel')}}" | ||
- "{{=jsonpath(workflow.annotations.json, '$.myAnnotation')}}" | ||
- "{{=jsonpath(workflow.parameters.json, '$[0].value')}}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed the dash from the name since expr expressions which include dash need to be formatted with brackets due to the special character
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you clarify with some examples? Does this mean names with dashes will not work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestion. I changed it back to the dashed name to show how you can handle that with expr.
BTW, this is the example Bala had, which I imitated.