Skip to content

Commit

Permalink
Exposed workflow priority as a variable (argoproj#1476)
Browse files Browse the repository at this point in the history
  • Loading branch information
markterm authored and Duske committed Aug 15, 2019
1 parent f44baf8 commit b35506b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
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

0 comments on commit b35506b

Please sign in to comment.