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: allow .artifacts.main-logs and workflow.failures variables #13714

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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: 2 additions & 0 deletions workflow/validate/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,8 @@ func resolveAllVariables(scope map[string]interface{}, globalParams map[string]s
} else if strings.HasPrefix(trimmedTag, "tasks.name") {
} else if strings.HasPrefix(trimmedTag, "steps.name") {
} else if strings.HasPrefix(trimmedTag, "node.name") {
} else if strings.HasPrefix(trimmedTag, "workflow.failures") {
} else if strings.HasSuffix(trimmedTag, ".artifacts.main-logs") {
} else if strings.HasPrefix(trimmedTag, "workflow.parameters") && workflowTemplateValidation {
// If we are simply validating a WorkflowTemplate in isolation, some of the parameters may come from the Workflow that uses it
} else {
Expand Down
23 changes: 21 additions & 2 deletions workflow/validate/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1029,6 +1029,21 @@ spec:
var workflowStatusNotOnExit = `
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: exit-handlers-
spec:
entrypoint: pass
templates:
- name: pass
container:
image: alpine:latest
command: [sh, -c]
args: ["echo {{workflow.status}}"]
`

var workflowFailures = `
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: exit-handlers-
spec:
Expand All @@ -1042,9 +1057,13 @@ spec:
`

func TestExitHandler(t *testing.T) {
// ensure {{workflow.status}} is not available when not in exit handler
// ensure {{workflow.status}} is available when not in exit handler
err := validate(workflowStatusNotOnExit)
require.Error(t, err)
require.NoError(t, err)

// ensure {{workflow.failures}} is available
err = validate(workflowFailures)
require.NoError(t, err)

// ensure {{workflow.status}} is available in exit handler
err = validate(exitHandlerWorkflowStatusOnExit)
Expand Down
Loading