Version: v1.1

Step Operations

This documentation will introduce the CUE operations provided in vela/op stdlib package that can be used in each workflow step.

To learn the syntax of CUE, read CUE Basic

Apply


Create or update resource in Kubernetes cluster.

Action Parameter

  • value: the resource structure to be created or updated. And after successful execution, value will be updated with resource status.
  • patch: the content support Strategic Merge Patch,let you can define the strategy of list merge through comments.
  1. #Apply: {
  2. value: {...}
  3. patch: {
  4. //patchKey=$key
  5. ...
  6. }
  7. }

Usage

  1. import "vela/op"
  2. stepName: op.#Apply & {
  3. value: {
  4. kind: "Deployment"
  5. apiVersion: "apps/v1"
  6. metadata: name: "test-app"
  7. spec: {
  8. replicas: 2
  9. ...
  10. }
  11. }
  12. patch: {
  13. spec: template: spec: {
  14. //patchKey=name
  15. containers: [{name: "sidecar"}]
  16. }
  17. }
  18. }

ConditionalWait


Step will be blocked until the condition is met.

Action Parameter

  • continue: Step will be blocked until the value becomes true.
  1. #ConditionalWait: {
  2. continue: bool
  3. }

Usage

  1. import "vela/op"
  2. apply: op.#Apply
  3. wait: op.#ConditionalWait: {
  4. continue: apply.value.status.phase=="running"
  5. }

Load


Get all components in application.

Action Parameter

No parameters.

  1. #Load: {}

Usage

  1. import "vela/op"
  2. // You can use `load.value.[componentName] after this action.
  3. load: op.#Load & {}

Read


Get resource in Kubernetes cluster.

Action Parameter

  • value: the resource metadata to be get. And after successful execution, value will be updated with resource definition in cluster.
  • err: if an error occurs, the err will contain the error message.
  1. #Read: {
  2. value: {}
  3. err?: string
  4. }

Usage

  1. // You can use configmap.value.data after this action.
  2. configmap: op.#Read & {
  3. value: {
  4. kind: "ConfigMap"
  5. apiVersion: "v1"
  6. metadata: {
  7. name: "configmap-name"
  8. namespace: "configmap-ns"
  9. }
  10. }
  11. }

ApplyApplication


Create or update resources corresponding to the application in Kubernetes cluster.

Action Parameter

No parameters.

  1. #ApplyApplication: {}

Usage

  1. apply: op.#ApplyApplication & {}

ApplyComponent


Create or update resources corresponding to the component in Kubernetes cluster. Note that need to use Load first to apply the resources.

Action Parameter

  • value: the load value of the resource.
  • patch: the value to patch resource.
  1. #ApplyComponent: {
  2. value: {...}
  3. patch: {...}
  4. }

Usage

  1. load: op.#Load & {}
  2. apply: op.#ApplyComponent & {
  3. value: load.value[parameter.component]
  4. }

ApplyRemaining


Create or update the resources corresponding to all components in the application in the Kubernetes cluster, and specify which components do not need to apply through exceptions, or skip some resources of the exceptional component.

Action Parameter

  • exceptions: indicates the name of the exceptional component.
  1. #ApplyRemaining: {
  2. exceptions?: [...string]
  3. }

Usage

  1. apply: op.#ApplyRemaining & {
  2. exceptions: ["applied-component-name"]
  3. }

Slack


Send messages to Slack.

Action Parameter

  • url: The webhook address of Slack.
  • message: The messages that you want to send, please refer to Slack messaging
  1. #Slack: {
  2. url: string
  3. message: {...}
  4. }

Usage

  1. apply: op.#Slack & {
  2. url: webhook url
  3. message:
  4. text: Hello KubeVela
  5. }

DingTalk


Send messages to DingTalk.

Action Parameter

  • url: The webhook address of DingTalk.
  • message: The messages that you want to send, please refer to DingTalk messaging
  1. #DingTalk: {
  2. url: string
  3. message: {...}
  4. }

Usage

  1. apply: op.#DingTalk & {
  2. url: webhook url
  3. message:
  4. msgtype: text
  5. text:
  6. context: Hello KubeVela
  7. }

Steps


Used to encapsulate a set of operations.

  • In steps, you need to specify the execution order by tag.

Usage

  1. app: op.#Steps & {
  2. load: op.#Load & {
  3. component: "component-name"
  4. } @step(1)
  5. apply: op.#Apply & {
  6. value: load.value.workload
  7. } @step(2)
  8. }

DoVar


used to save or read user-defined data in the context of workflow

Action Parameter

  • method: The value is get or put, which indicates whether the action reads or saves data from workflow
  • path: Path to save or read data
  • value: Data content (in the format of cue). When the method is get, it indicates the read data, otherwise it indicates the data to be saved

Usage

  1. put: op.ws.#DoVar & {
  2. method: "Put"
  3. path: "foo.score"
  4. value: 100
  5. }
  6. // The user can get the data saved above through get.value (100)
  7. get: op.ws.#DoVar & {
  8. method: "Get"
  9. path: "foo.score"
  10. }