fix: generate manifests

This commit is contained in:
anhoder
2021-11-26 13:56:54 +08:00
parent 87efbfdfa3
commit 3760ed2325
2 changed files with 26 additions and 10 deletions

22
hack/generate_manifests.sh Executable file
View File

@@ -0,0 +1,22 @@
#!/bin/bash
set -ex
CRD_OPTIONS="$1"
PKGS="$2"
IFS=" " read -r -a PKGS <<< "${PKGS}"
KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
cd "${KUBE_ROOT}" || exit
for PKG in "${PKGS[@]}"; do
echo "Generating manifests for ${PKG}"
if [[ "$PKG" =~ /\*$ ]]; then
PKG=${PKG%??}
DIR=$(go list -e -test=false -export=false -deps=false -find=false -tags ignore_autogenerated -f "{{.Dir}}" "kubesphere.io/api/${PKG}")
# shellcheck disable=SC2010
ls -1 -F "${DIR}" | grep '/$' | xargs -n 1 -I{} go run ./vendor/sigs.k8s.io/controller-tools/cmd/controller-gen/main.go object:headerFile=./hack/boilerplate.go.txt paths=kubesphere.io/api/"${PKG}"/{} rbac:roleName=controller-perms "${CRD_OPTIONS}" output:crd:artifacts:config=config/crds
else
go run ./vendor/sigs.k8s.io/controller-tools/cmd/controller-gen/main.go object:headerFile=./hack/boilerplate.go.txt paths=kubesphere.io/api/"${PKG}" rbac:roleName=controller-perms "${CRD_OPTIONS}" output:crd:artifacts:config=config/crds
fi
done