Feat(workflow): add depends-on workflow step definition (#2190)

This commit is contained in:
yangsoon
2021-08-30 17:19:32 +08:00
committed by GitHub
parent 25bc43ae39
commit 75a972516d
2 changed files with 129 additions and 0 deletions
@@ -0,0 +1,65 @@
# Code generated by KubeVela templates. DO NOT EDIT. Please edit the original cue file.
# Definition source cue file: vela-templates/definitions/internal/depends-on-app.cue
apiVersion: core.oam.dev/v1beta1
kind: WorkflowStepDefinition
metadata:
annotations:
definition.oam.dev/description: check or install depends-on Application
name: depends-on-app
namespace: {{.Values.systemDefinitionNamespace}}
spec:
schematic:
cue:
template: |
import (
"vela/op"
"encoding/yaml"
)
dependsOn: op.#Read & {
value: {
apiVersion: "core.oam.dev/v1beta1"
kind: "Application"
metadata: {
name: parameter.name
namespace: parameter.namespace
}
}
}
load: op.#Steps & {
if dependsOn.err != _|_ {
configMap: op.#Read & {
value: {
apiVersion: "v1"
kind: "ConfigMap"
metadata: {
name: parameter.name
namespace: parameter.namespace
}
}
}
apply: op.#Apply & {
value: {
yaml.Unmarshal(configMap.value.data[parameter.name])
}
}
}
if dependsOn.err == _|_ {
apply: op.#Apply & {
value: {
dependsOn.value
}
}
}
}
phase: load.apply.value.status.status
wait: op.#ConditionalWait & {
continue: phase == "running"
}
parameter: {
// +usage=Specify the name of the dependent Application
name: string
// +usage=Specify the namespace of the dependent Application
namespace: string
}
@@ -0,0 +1,64 @@
import (
"vela/op"
"encoding/yaml"
)
"depends-on-app": {
type: "workflow-step"
annotations: {}
labels: {}
description: "check or install depends-on Application"
}
template: {
dependsOn: op.#Read & {
value: {
apiVersion: "core.oam.dev/v1beta1"
kind: "Application"
metadata: {
name: parameter.name
namespace: parameter.namespace
}
}
}
load: op.#Steps & {
if dependsOn.err != _|_ {
configMap: op.#Read & {
value: {
apiVersion: "v1"
kind: "ConfigMap"
metadata: {
name: parameter.name
namespace: parameter.namespace
}
}
}
apply: op.#Apply & {
value: {
yaml.Unmarshal(configMap.value.data[parameter.name])
}
}
}
if dependsOn.err == _|_ {
apply: op.#Apply & {
value: {
dependsOn.value
}
}
}
}
phase: load.apply.value.status.status
wait: op.#ConditionalWait & {
continue: phase == "running"
}
parameter: {
// +usage=Specify the name of the dependent Application
name: string
// +usage=Specify the namespace of the dependent Application
namespace: string
}
}