mirror of
https://github.com/kubevela/kubevela.git
synced 2026-02-14 10:00:06 +00:00
Feat: add gen-cue to Makefile (#6009)
Signed-off-by: iyear <ljyngup@gmail.com>
This commit is contained in:
40
hack/cuegen/cuegen.sh
Normal file
40
hack/cuegen/cuegen.sh
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# Usage: cuegen.sh dir [flagsToVela]
|
||||||
|
# Example: cuegen.sh references/cuegen/generators/provider/testdata/ \
|
||||||
|
# -t provider \
|
||||||
|
# --types *k8s.io/apimachinery/pkg/apis/meta/v1/unstructured.Unstructured=ellipsis
|
||||||
|
|
||||||
|
|
||||||
|
# check vela binary
|
||||||
|
if ! [ -x "$(command -v vela)" ]; then
|
||||||
|
echo "Please put vela binary in the PATH"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# get dir from first arg
|
||||||
|
dir="$1"
|
||||||
|
if [ -z "$dir" ]; then
|
||||||
|
echo "Please provide a directory"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Generating CUE files from go files in $dir"
|
||||||
|
echo "========"
|
||||||
|
|
||||||
|
find "$dir" -name "*.go" | while read -r file; do
|
||||||
|
echo "- Generating CUE file for $file"
|
||||||
|
|
||||||
|
# redirect output if command exits successfully
|
||||||
|
(out=$(vela def gen-cue ${*:2} "$file") && echo "$out" > "${file%.go}".cue) &
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "========"
|
||||||
|
echo "Waiting for all background processes to finish"
|
||||||
|
|
||||||
|
wait
|
||||||
|
sleep 5s # wait for all stderr to be printed
|
||||||
|
|
||||||
|
echo "Done"
|
||||||
@@ -24,4 +24,9 @@ core-debug-run: fmt vet manifests
|
|||||||
# Run against the configured Kubernetes cluster in ~/.kube/config
|
# Run against the configured Kubernetes cluster in ~/.kube/config
|
||||||
.PHONY: core-run
|
.PHONY: core-run
|
||||||
core-run: fmt vet manifests
|
core-run: fmt vet manifests
|
||||||
go run ./cmd/core/main.go
|
go run ./cmd/core/main.go
|
||||||
|
|
||||||
|
## gen-cue: Generate CUE files from Go files. Variable DIR is the directory of the Go files, FLAGS is the flags for vela def gen-cue command.
|
||||||
|
.PHONY: gen-cue
|
||||||
|
gen-cue:
|
||||||
|
./hack/cuegen/cuegen.sh $(DIR) $(FLAGS)
|
||||||
|
|||||||
Reference in New Issue
Block a user