diff --git a/charts/vela-core/templates/defwithtemplate/apply-application.yaml b/charts/vela-core/templates/defwithtemplate/apply-application.yaml new file mode 100644 index 000000000..62409ab29 --- /dev/null +++ b/charts/vela-core/templates/defwithtemplate/apply-application.yaml @@ -0,0 +1,20 @@ +# Code generated by KubeVela templates. DO NOT EDIT. Please edit the original cue file. +# Definition source cue file: vela-templates/definitions/internal/apply-application.cue +apiVersion: core.oam.dev/v1beta1 +kind: WorkflowStepDefinition +metadata: + annotations: + definition.oam.dev/description: Apply application for your workflow steps + name: apply-application + namespace: {{.Values.systemDefinitionNamespace}} +spec: + schematic: + cue: + template: | + import ( + "vela/op" + ) + + // apply application + output: op.#ApplyApplication & {} + diff --git a/pkg/stdlib/op.cue b/pkg/stdlib/op.cue index 363b1d12b..0642297ab 100644 --- a/pkg/stdlib/op.cue +++ b/pkg/stdlib/op.cue @@ -15,6 +15,23 @@ import ( #Apply: kube.#Apply +#ApplyApplication: #Steps & { + load: ws.#Load @step(1) + components: #Steps & { + for name, c in load.value { + "\(name)": #Steps & { + workload: kube.#Apply & {value: c.workload} + if c.auxiliaries != _|_ { + _key: "trait.oam.dev/resource" + for index, o in c.auxiliaries { + "\(o.metadata.labels[_key])": kube.#Apply & {value: o} + } + } + } + } + } @step(2) +} + #ApplyComponent: #Steps & { component: string diff --git a/vela-templates/definitions/internal/apply-application.cue b/vela-templates/definitions/internal/apply-application.cue new file mode 100644 index 000000000..b9b871ef2 --- /dev/null +++ b/vela-templates/definitions/internal/apply-application.cue @@ -0,0 +1,14 @@ +import ( + "vela/op" +) + +"apply-application": { + type: "workflow-step" + annotations: {} + labels: {} + description: "Apply application for your workflow steps" +} +template: { + // apply application + output: op.#ApplyApplication & {} +}