Built-in Workflow Operations


    Create or update resource in Kubernetes cluster.

    • 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.

    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. spec: template: spec: {
    13. //patchKey=name
    14. containers: [{name: "sidecar"}]
    15. }
    16. }
    17. }

    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

    1. #Load: {}

    Usage

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

    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. // 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. value: load.value[parameter.component]
    3. }

    Action Parameter

    • exceptions: indicates the name of the exceptional component.

    Usage

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

    Slack


    Send messages to Slack.

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

    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 。
    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. }

    Used to encapsulate a set of operations.

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

    Usage

    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"