Built-in Workflow Operations
This document introduces the CUE operations that can be used in the workflow step definitions. You need to import the vela/op package to use these operations.
tip
Before reading this section, make sure you understand how to customize workflow and learn the basics of CUE
Process Control
ConditionalWait
Makes the workflow step wait until the condition is met.
Parameters
#ConditionalWait: {
// +usage=If continue is false, the step will wait for continue to be true.
continue: bool
// +usage=Optional message that will be shown in workflow step status, note that the message might be override by other actions.
message?: string
}
Example
import "vela/op"
myRead: op.#Read & {
value: {
kind: "Deployment"
apiVersion: "apps/v1"
metadata: name: "test-app"
}
}
wait: op.#ConditionalWait & {
continue: myRead.value.status.phase == "running"
}
Fail
Make the workflow step failed.
Parameters
#Fail: {
// +usage=Optional message that will be shown in workflow step status, note that the message might be override by other actions.
message?: string
}
Example
import "vela/op"
fail: op.#Fail & {
message: "error in the step"
}
Data Control
Log
Output the log or configure the log source for this step. If op.#Log is used in a step definition, then you can use vela workflow logs <name> to view the log for that step.
Parameters
#Log: {
// +usage=The data to print in the controller logs
data?: {...} | string
// +usage=The log level of the data
level: *3 | int
// +usage=The log source of this step. You can specify it from a url or resources. Note that if you set source in multiple op.#Log, only the latest one will work
source?: close({
// +usage=Specify the log source url of this step
url: string
}) | close({
// +usage=Specify the log resources of this step
resources?: [...{
// +usage=Specify the name of the resource
name?: string
// +usage=Specify the cluster of the resource
cluster?: string
// +usage=Specify the namespace of the resource
namespace?: string
// +usage=Specify the label selector of the resource
labelSelector?: {...}
}]
})
}
Example
import "vela/op"
myLog: op.#Log & {
data: "my custom log"
resources: [{
labelsSelector: {"test-key": "test-value"}
}]
}
Message
Write message to the workflow step status.
Parameters
#Message: {
// +usage=Optional message that will be shown in workflow step status, note that the message might be override by other actions.
message?: string
}
Example
import "vela/op"
msg: op.#Message & {
message: "custom message"
}
DoVar
Used to save or read user-defined data in the context of workflow.
Parameters
#DoVar: {
// +usage=The method to call on the variable
method: *"Get" | "Put"
// +usage=The path to the variable
path: string
// +usage=The value of the variable
value?: _
}
Example
put: op.ws.#DoVar & {
method: "Put"
path: "foo.score"
value: 100
}
// The user can get the data saved above through get.value (100)
get: op.ws.#DoVar & {
method: "Get"
path: "foo.score"
}