mirror of
https://github.com/kubevela/kubevela.git
synced 2026-08-19 04:26:39 +00:00
feat(def): add built-in workflow definitions (#2094)
* use_vela_bin * Update gen_definitions.sh add version print * Update gen_definitions.sh * Update gen_definitions.sh * update crossplatform build check * test * feat(def): add built-in workflow definitions * delete pod disruptive in workflow step def * make cue files reviewable * fix workflow step definition * fix ci * add clean up step * add build clean up Co-authored-by: Yin Da <yd219913@alibaba-inc.com> Co-authored-by: Somefive <Somefive@foxmail.com>
This commit is contained in:
co-authored by
Yin Da
Somefive
parent
2854c4204c
commit
601510e43c
@@ -139,7 +139,7 @@ jobs:
|
||||
version: ${{ env.GOLANGCI_VERSION }}
|
||||
|
||||
check-diff:
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: aliyun
|
||||
needs: detect-noop
|
||||
if: needs.detect-noop.outputs.noop != 'true'
|
||||
|
||||
@@ -164,25 +164,11 @@ jobs:
|
||||
- name: Check code formatting
|
||||
run: go install golang.org/x/tools/cmd/goimports && make fmt
|
||||
|
||||
- name: Check Diff
|
||||
run: make check-diff
|
||||
|
||||
build-cli:
|
||||
runs-on: ubuntu-latest
|
||||
needs: detect-noop
|
||||
if: needs.detect-noop.outputs.noop != 'true'
|
||||
|
||||
steps:
|
||||
- name: Set up Go 1.16
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: ${{ env.GO_VERSION }}
|
||||
id: go
|
||||
- name: Check out code into the Go module directory
|
||||
uses: actions/checkout@v2
|
||||
- name: Run cross-build
|
||||
run: make cross-build
|
||||
- name: Run compress binary
|
||||
run: make compress
|
||||
- name: Run make reviewable
|
||||
run: make reviewable
|
||||
|
||||
- name: Check Diff
|
||||
run: make check-diff
|
||||
|
||||
- name: Cleanup binary
|
||||
run: make build-cleanup
|
||||
|
||||
@@ -91,6 +91,9 @@ cross-build:
|
||||
$(GOBUILD_ENV) $(GOX) -ldflags $(LDFLAGS) -parallel=2 -output="_bin/kubectl-vela/{{.OS}}-{{.Arch}}/kubectl-vela" -osarch='$(TARGETS)' ./cmd/plugin
|
||||
$(GOBUILD_ENV) $(GOX) -ldflags $(LDFLAGS) -parallel=2 -output="_bin/apiserver/{{.OS}}-{{.Arch}}/apiserver" -osarch="$(TARGETS)" ./cmd/apiserver
|
||||
|
||||
build-cleanup:
|
||||
rm -rf _bin
|
||||
|
||||
compress:
|
||||
( \
|
||||
echo "\n## Release Info\nVERSION: $(VELA_VERSION)" >> README.md && \
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
# Code generated by KubeVela templates. DO NOT EDIT. Please edit the original cue file.
|
||||
# Definition source cue file: vela-templates/definitions/internal/apply-component.cue
|
||||
apiVersion: core.oam.dev/v1beta1
|
||||
kind: WorkflowStepDefinition
|
||||
metadata:
|
||||
annotations:
|
||||
definition.oam.dev/description: Apply components and traits for your workflow steps
|
||||
name: apply-component
|
||||
namespace: {{.Values.systemDefinitionNamespace}}
|
||||
spec:
|
||||
schematic:
|
||||
cue:
|
||||
template: |
|
||||
import (
|
||||
"vela/op"
|
||||
)
|
||||
|
||||
// apply components and traits
|
||||
apply: op.#ApplyComponent & {
|
||||
component: parameter.component
|
||||
}
|
||||
parameter: {
|
||||
// +usage=Declare the name of the component
|
||||
component: string
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
# Code generated by KubeVela templates. DO NOT EDIT. Please edit the original cue file.
|
||||
# Definition source cue file: vela-templates/definitions/internal/apply-remaining.cue
|
||||
apiVersion: core.oam.dev/v1beta1
|
||||
kind: WorkflowStepDefinition
|
||||
metadata:
|
||||
annotations:
|
||||
definition.oam.dev/description: Apply remaining components and traits
|
||||
name: apply-remaining
|
||||
namespace: {{.Values.systemDefinitionNamespace}}
|
||||
spec:
|
||||
schematic:
|
||||
cue:
|
||||
template: |
|
||||
import (
|
||||
"vela/op"
|
||||
)
|
||||
|
||||
// apply remaining components and traits
|
||||
apply: op.#ApplyRemaining & {
|
||||
parameter
|
||||
}
|
||||
parameter: {
|
||||
// +usage=Declare the name of the component
|
||||
exceptions?: [componentName=string]: {
|
||||
// +usage=skipApplyWorkload indicates whether to skip apply the workload resource
|
||||
skipApplyWorkload: *true | bool
|
||||
|
||||
// +usage=skipAllTraits indicates to skip apply all resources of the traits.
|
||||
// +usage=If this is true, skipApplyTraits will be ignored
|
||||
skipAllTraits: *true | bool
|
||||
|
||||
// +usage=skipApplyTraits specifies the names of the traits to skip apply
|
||||
skipApplyTraits: [...string]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
# Code generated by KubeVela templates. DO NOT EDIT. Please edit the original cue file.
|
||||
# Definition source cue file: vela-templates/definitions/internal/multi-env.cue
|
||||
apiVersion: core.oam.dev/v1beta1
|
||||
kind: WorkflowStepDefinition
|
||||
metadata:
|
||||
annotations:
|
||||
definition.oam.dev/description: Apply env binding component
|
||||
name: multi-env
|
||||
namespace: {{.Values.systemDefinitionNamespace}}
|
||||
spec:
|
||||
schematic:
|
||||
cue:
|
||||
template: |
|
||||
import (
|
||||
"vela/op"
|
||||
)
|
||||
|
||||
component: op.#ApplyEnvBindComponent & {
|
||||
env: parameter.env
|
||||
policy: parameter.policy
|
||||
component: parameter.component
|
||||
// context.namespace indicates the namespace of the app
|
||||
namespace: context.namespace
|
||||
}
|
||||
parameter: {
|
||||
// +usage=Declare the name of the component
|
||||
component: string
|
||||
// +usage=Declare the name of the policy
|
||||
policy: string
|
||||
// +usage=Declare the name of the env in policy
|
||||
env: string
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
import (
|
||||
"vela/op"
|
||||
)
|
||||
|
||||
"apply-component": {
|
||||
type: "workflow-step"
|
||||
annotations: {}
|
||||
labels: {}
|
||||
description: "Apply components and traits for your workflow steps"
|
||||
}
|
||||
template: {
|
||||
// apply components and traits
|
||||
apply: op.#ApplyComponent & {
|
||||
component: parameter.component
|
||||
}
|
||||
|
||||
parameter: {
|
||||
// +usage=Declare the name of the component
|
||||
component: string
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
import (
|
||||
"vela/op"
|
||||
)
|
||||
|
||||
"apply-remaining": {
|
||||
type: "workflow-step"
|
||||
annotations: {}
|
||||
labels: {}
|
||||
description: "Apply remaining components and traits"
|
||||
}
|
||||
template: {
|
||||
// apply remaining components and traits
|
||||
apply: op.#ApplyRemaining & {
|
||||
parameter
|
||||
}
|
||||
|
||||
parameter: {
|
||||
// +usage=Declare the name of the component
|
||||
exceptions?: [componentName=string]: {
|
||||
// +usage=skipApplyWorkload indicates whether to skip apply the workload resource
|
||||
skipApplyWorkload: *true | bool
|
||||
|
||||
// +usage=skipAllTraits indicates to skip apply all resources of the traits.
|
||||
// +usage=If this is true, skipApplyTraits will be ignored
|
||||
skipAllTraits: *true | bool
|
||||
|
||||
// +usage=skipApplyTraits specifies the names of the traits to skip apply
|
||||
skipApplyTraits: [...string]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
import (
|
||||
"vela/op"
|
||||
)
|
||||
|
||||
"multi-env": {
|
||||
type: "workflow-step"
|
||||
annotations: {}
|
||||
labels: {}
|
||||
description: "Apply env binding component"
|
||||
}
|
||||
template: {
|
||||
component: op.#ApplyEnvBindComponent & {
|
||||
env: parameter.env
|
||||
policy: parameter.policy
|
||||
component: parameter.component
|
||||
// context.namespace indicates the namespace of the app
|
||||
namespace: context.namespace
|
||||
}
|
||||
|
||||
parameter: {
|
||||
// +usage=Declare the name of the component
|
||||
component: string
|
||||
// +usage=Declare the name of the policy
|
||||
policy: string
|
||||
// +usage=Declare the name of the env in policy
|
||||
env: string
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,12 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
export IGNORE_KUBE_CONFIG=true
|
||||
|
||||
LIGHTGRAY='\033[0;37m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
RED='\033[0;31m'
|
||||
NC='\033[0m'
|
||||
|
||||
HEAD_PROMPT="${LIGHTGRAY}[${0}]${NC} "
|
||||
@@ -17,16 +19,42 @@ REGISTRY_DEFINITION_DIR="definitions/registry"
|
||||
INTERNAL_TEMPLATE_DIR="../charts/vela-core/templates/defwithtemplate"
|
||||
REGISTRY_TEMPLATE_DIR="registry/auto-gen"
|
||||
|
||||
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
|
||||
ARCH=""
|
||||
case $(uname -m) in
|
||||
i386) ARCH="386" ;;
|
||||
i686) ARCH="386" ;;
|
||||
x86_64) ARCH="amd64" ;;
|
||||
arm) ARCH="arm64" ;;
|
||||
esac
|
||||
|
||||
VELA_CMD="../bin/vela"
|
||||
if [ ! -f "$VELA_CMD" ]; then
|
||||
VELA_CMD="../_bin/vela/$OS-$ARCH/vela"
|
||||
echo -e "${HEAD_PROMPT}${LIGHTGRAY}Search cross build vela binary in ${VELA_CMD}.${NC}"
|
||||
fi
|
||||
if [ ! -f "$VELA_CMD" ]; then
|
||||
echo -e "${HEAD_PROMPT}${YELLOW}Failed to get vela command, fallback to use \`go run\`.${NC}"
|
||||
VELA_CMD="go run ../references/cmd/cli/main.go"
|
||||
else
|
||||
echo -e "${HEAD_PROMPT}${GREEN}Got vela command binary."
|
||||
$VELA_CMD version
|
||||
fi
|
||||
|
||||
function render {
|
||||
inputDir=$1
|
||||
outputDir=$2
|
||||
rm "$outputDir"/* 2>/dev/null || true
|
||||
mkdir -p "$outputDir"
|
||||
go run ../references/cmd/cli/main.go def render "$inputDir" -o "$outputDir" --message "Definition source cue file: vela-templates/$inputDir/{{INPUT_FILENAME}}"
|
||||
$VELA_CMD def render "$inputDir" -o "$outputDir" --message "Definition source cue file: vela-templates/$inputDir/{{INPUT_FILENAME}}"
|
||||
retVal=$?
|
||||
if [ $retVal -ne 0 ]; then
|
||||
echo -ne "${RED}Failed. Exit code: ${retVal}.${NC}\n"
|
||||
exit $retVal
|
||||
fi
|
||||
}
|
||||
|
||||
echo -e "${HEAD_PROMPT}Start generating definitions at ${LIGHTGRAY}${SCRIPT_DIR}${NC} ..."
|
||||
export IGNORE_KUBE_CONFIG=true
|
||||
echo -ne "${HEAD_PROMPT}${YELLOW}(0/2) Generating internal definitions from ${LIGHTGRAY}${INTERNAL_DEFINITION_DIR}${YELLOW} to ${LIGHTGRAY}${INTERNAL_TEMPLATE_DIR}${YELLOW} ... "
|
||||
export AS_HELM_CHART=true
|
||||
render $INTERNAL_DEFINITION_DIR $INTERNAL_TEMPLATE_DIR
|
||||
|
||||
Reference in New Issue
Block a user