Skip to content

Commit 082e5c4

Browse files
marktermjessesuen
authored andcommitted
Exposed workflow priority as a variable (#1476)
1 parent 38c4def commit 082e5c4

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

docs/variables.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ The following variables are made available to reference various metadata of a wo
5151
| `workflow.labels.<NAME>` | Workflow labels |
5252
| `workflow.creationTimestamp` | Workflow creation timestamp formatted in RFC 3339 (e.g. `2018-08-23T05:42:49Z`) |
5353
| `workflow.creationTimestamp.<STRFTIMECHAR>` | Creation timestamp formatted with a [strftime](http://strftime.org) format character |
54-
54+
| `workflow.priority` | Workflow priority |
5555

5656
## Exit Handler:
5757
| Variable | Description|

workflow/common/common.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,10 @@ const (
109109
GlobalVarWorkflowUID = "workflow.uid"
110110
// GlobalVarWorkflowStatus is a global workflow variable referencing the workflow's status.phase field
111111
GlobalVarWorkflowStatus = "workflow.status"
112-
// GlobalVarWorkflowCreationTimestamp is the workflow variable referencing the workflows metadata.creationTimestamp field
112+
// GlobalVarWorkflowCreationTimestamp is the workflow variable referencing the workflow's metadata.creationTimestamp field
113113
GlobalVarWorkflowCreationTimestamp = "workflow.creationTimestamp"
114+
// GlobalVarWorkflowPriority is the workflow variable referencing the workflow's priority field
115+
GlobalVarWorkflowPriority = "workflow.priority"
114116
// LocalVarPodName is a step level variable that references the name of the pod
115117
LocalVarPodName = "pod.name"
116118

workflow/controller/operator.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,9 @@ func (woc *wfOperationCtx) setGlobalParameters() {
265265
woc.globalParams[common.GlobalVarWorkflowNamespace] = woc.wf.ObjectMeta.Namespace
266266
woc.globalParams[common.GlobalVarWorkflowUID] = string(woc.wf.ObjectMeta.UID)
267267
woc.globalParams[common.GlobalVarWorkflowCreationTimestamp] = woc.wf.ObjectMeta.CreationTimestamp.String()
268+
if woc.wf.Spec.Priority != nil {
269+
woc.globalParams[common.GlobalVarWorkflowPriority] = strconv.Itoa(int(*woc.wf.Spec.Priority))
270+
}
268271
for char := range strftime.FormatChars {
269272
cTimeVar := fmt.Sprintf("%s.%s", common.GlobalVarWorkflowCreationTimestamp, string(char))
270273
woc.globalParams[cTimeVar] = strftime.Format("%"+string(char), woc.wf.ObjectMeta.CreationTimestamp.Time)

0 commit comments

Comments
 (0)