Skip to content

Commit

Permalink
fix(controller): allow workflow.duration to pass validator
Browse files Browse the repository at this point in the history
Signed-off-by: Tianchu Zhao <[email protected]>
  • Loading branch information
tczhao committed Jul 20, 2021
1 parent d6ec032 commit 1760099
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -956,7 +956,7 @@ spec:
container:
image: alpine:latest
command: [sh, -c]
args: ["echo send e-mail: {{workflow.name}} {{workflow.status}}"]
args: ["echo send e-mail: {{workflow.name}} {{workflow.status}} {{workflow.duration}}"]
- name: celebrate
container:
image: alpine:latest
Expand Down
2 changes: 1 addition & 1 deletion examples/exit-handlers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ spec:
#
# Will print a list of all the failed steps and their messages. For more info look up the jq docs.
# Note: jq is not installed by default on the "alpine:latest" image, however it can be installed with "apk add jq"
args: ["echo send e-mail: {{workflow.name}} {{workflow.status}}. Failed steps {{workflow.failures}}"]
args: ["echo send e-mail: {{workflow.name}} {{workflow.status}} {{workflow.duration}}. Failed steps {{workflow.failures}}"]
- name: celebrate
container:
image: alpine:latest
Expand Down
2 changes: 1 addition & 1 deletion workflow/controller/operator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3202,7 +3202,7 @@ spec:
container:
image: alpine:latest
command: [sh, -c]
args: ["echo send e-mail: {{workflow.name}} {{workflow.status}}. Failed steps {{workflow.failures}}"]
args: ["echo send e-mail: {{workflow.name}} {{workflow.status}} {{workflow.duration}}. Failed steps {{workflow.failures}}"]
`

func TestStepsOnExitFailures(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions workflow/validate/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,7 @@ func resolveAllVariables(scope map[string]interface{}, tmplStr string) error {
} else if strings.HasPrefix(tag, common.GlobalVarWorkflowCreationTimestamp) {
} else if strings.HasPrefix(tag, common.GlobalVarWorkflowCronScheduleTime) {
// Allow runtime resolution for "scheduledTime" which will pass from CronWorkflow
} else if strings.HasPrefix(tag, common.GlobalVarWorkflowDuration) {
} else {
return fmt.Errorf("failed to resolve {{%s}}", tag)
}
Expand Down
9 changes: 6 additions & 3 deletions workflow/validate/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -970,7 +970,7 @@ spec:
container:
image: alpine:latest
command: [sh, -c]
args: ["echo {{workflow.status}} {{workflow.uid}}"]
args: ["echo {{workflow.status}} {{workflow.uid}} {{workflow.duration}}"]
`

var workflowStatusNotOnExit = `
Expand Down Expand Up @@ -2172,7 +2172,9 @@ spec:
- name: uid
value: "{{workflow.uid}}"
- name: priority
value: "{{workflow.priority}}"
value: "{{workflow.priority}}"
- name: duration
value: "{{workflow.duration}}"
- name: whalesay
inputs:
Expand All @@ -2182,10 +2184,11 @@ spec:
- name: serviceAccountName
- name: uid
- name: priority
- name: duration
container:
image: docker/whalesay:latest
command: [cowsay]
args: ["name: {{inputs.parameters.name}} namespace: {{inputs.parameters.namespace}} serviceAccountName: {{inputs.parameters.serviceAccountName}} uid: {{inputs.parameters.uid}} priority: {{inputs.parameters.priority}}"]
args: ["name: {{inputs.parameters.name}} namespace: {{inputs.parameters.namespace}} serviceAccountName: {{inputs.parameters.serviceAccountName}} uid: {{inputs.parameters.uid}} priority: {{inputs.parameters.priority}} duration: {{inputs.parameters.duration}}"]
`

func TestWorkflowGlobalVariables(t *testing.T) {
Expand Down

0 comments on commit 1760099

Please sign in to comment.