Skip to content
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(controller): allow workflow.duration to pass validator #6376

Merged
merged 1 commit into from
Jul 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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