github.com/kubevela/workflow@v0.6.0/charts/vela-workflow/templates/definitions/addon-operation.yaml (about)

     1  # Code generated by KubeVela templates. DO NOT EDIT. Please edit the original cue file.
     2  # Definition source cue file: vela-templates/definitions/internal/addon-operation.cue
     3  apiVersion: core.oam.dev/v1beta1
     4  kind: WorkflowStepDefinition
     5  metadata:
     6    annotations:
     7      definition.oam.dev/description: Enable a KubeVela addon
     8      definition.oam.dev/example-url: https://raw.githubusercontent.com/kubevela/catalog/master/examples/vela-workflow/observability.yaml
     9    labels:
    10      custom.definition.oam.dev/scope: WorkflowRun
    11    name: addon-operation
    12    namespace: {{ include "systemDefinitionNamespace" . }}
    13  spec:
    14    schematic:
    15      cue:
    16        template: |
    17          import (
    18          	"vela/op"
    19          )
    20  
    21          job: op.#Apply & {
    22          	value: {
    23          		apiVersion: "batch/v1"
    24          		kind:       "Job"
    25          		metadata: {
    26          			name:      context.name + "-" + context.stepSessionID
    27          			namespace: "vela-system"
    28          			labels: "enable-addon.oam.dev":          context.name
    29          			annotations: "workflow.oam.dev/step": context.stepName
    30          		}
    31          		spec: {
    32          			backoffLimit: 3
    33          			template: {
    34          				metadata: {
    35          					labels: {
    36          						"workflow.oam.dev/name":    context.name
    37          						"workflow.oam.dev/session": context.stepSessionID
    38          					}
    39          					annotations: "workflow.oam.dev/step": context.stepName
    40          				}
    41          				spec: {
    42          					containers: [
    43          						{
    44          							name:  parameter.addonName + "-enable-job"
    45          							image: parameter.image
    46  
    47          							if parameter.args == _|_ {
    48          								command: ["vela", "addon", parameter.operation, parameter.addonName]
    49          							}
    50  
    51          							if parameter.args != _|_ {
    52          								command: ["vela", "addon", parameter.operation, parameter.addonName] + parameter.args
    53          							}
    54          						},
    55          					]
    56          					restartPolicy:  "Never"
    57          					serviceAccount: parameter.serviceAccountName
    58          				}
    59          			}
    60          		}
    61          	}
    62          }
    63          log: op.#Log & {
    64          	source: resources: [{labelSelector: {
    65          		"workflow.oam.dev/name":    context.name
    66          		"workflow.oam.dev/session": context.stepSessionID
    67          	}}]
    68          }
    69          fail: op.#Steps & {
    70          	if job.value.status.failed != _|_ {
    71          		if job.value.status.failed > 2 {
    72          			breakWorkflow: op.#Fail & {
    73          				message: "enable addon failed"
    74          			}
    75          		}
    76          	}
    77          }
    78          wait: op.#ConditionalWait & {
    79          	continue: job.value.status.succeeded != _|_ && job.value.status.succeeded > 0
    80          }
    81          parameter: {
    82          	// +usage=Specify the name of the addon.
    83          	addonName: string
    84          	// +usage=Specify addon enable args.
    85          	args?: [...string]
    86          	// +usage=Specify the image
    87          	image: *"oamdev/vela-cli:v1.6.4" | string
    88          	// +usage=operation for the addon
    89          	operation: *"enable" | "upgrade" | "disable"
    90          	// +usage=specify serviceAccountName want to use
    91          	serviceAccountName: *"kubevela-vela-core" | string
    92          }
    93