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

Exposed workflow priority as a variable #1476

Merged
merged 2 commits into from
Jul 22, 2019
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 docs/variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ The following variables are made available to reference various metadata of a wo
| `workflow.labels.<NAME>` | Workflow labels |
| `workflow.creationTimestamp` | Workflow creation timestamp formatted in RFC 3339 (e.g. `2018-08-23T05:42:49Z`) |
| `workflow.creationTimestamp.<STRFTIMECHAR>` | Creation timestamp formatted with a [strftime](http://strftime.org) format character |

| `workflow.priority` | Workflow priority |

## Exit Handler:
| Variable | Description|
Expand Down
4 changes: 3 additions & 1 deletion workflow/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,10 @@ const (
GlobalVarWorkflowUID = "workflow.uid"
// GlobalVarWorkflowStatus is a global workflow variable referencing the workflow's status.phase field
GlobalVarWorkflowStatus = "workflow.status"
// GlobalVarWorkflowCreationTimestamp is the workflow variable referencing the workflows metadata.creationTimestamp field
// GlobalVarWorkflowCreationTimestamp is the workflow variable referencing the workflow's metadata.creationTimestamp field
GlobalVarWorkflowCreationTimestamp = "workflow.creationTimestamp"
// GlobalVarWorkflowPriority is the workflow variable referencing the workflow's priority field
GlobalVarWorkflowPriority = "workflow.priority"
// LocalVarPodName is a step level variable that references the name of the pod
LocalVarPodName = "pod.name"

Expand Down
3 changes: 3 additions & 0 deletions workflow/controller/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,9 @@ func (woc *wfOperationCtx) setGlobalParameters() {
woc.globalParams[common.GlobalVarWorkflowNamespace] = woc.wf.ObjectMeta.Namespace
woc.globalParams[common.GlobalVarWorkflowUID] = string(woc.wf.ObjectMeta.UID)
woc.globalParams[common.GlobalVarWorkflowCreationTimestamp] = woc.wf.ObjectMeta.CreationTimestamp.String()
if woc.wf.Spec.Priority != nil {
woc.globalParams[common.GlobalVarWorkflowPriority] = strconv.Itoa(int(*woc.wf.Spec.Priority))
}
for char := range strftime.FormatChars {
cTimeVar := fmt.Sprintf("%s.%s", common.GlobalVarWorkflowCreationTimestamp, string(char))
woc.globalParams[cTimeVar] = strftime.Format("%"+string(char), woc.wf.ObjectMeta.CreationTimestamp.Time)
Expand Down