chore: Generating CRDs supports multiple versions (#5497)

Generating CRDs supports multiple versions
This commit is contained in:
hongming
2023-01-31 15:23:12 +08:00
committed by GitHub
parent b5a070edeb
commit 129e6fbec3
58 changed files with 4061 additions and 4403 deletions

View File

@@ -6,6 +6,7 @@ CRD_OPTIONS="$1"
PKGS="$2"
GENS="$3"
IFS=" " read -r -a PKGS <<< "${PKGS}"
export GOFLAGS=-mod=readonly
KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
cd "${KUBE_ROOT}" || exit
@@ -13,23 +14,9 @@ cd "${KUBE_ROOT}" || exit
for PKG in "${PKGS[@]}"; do
if grep -qw "deepcopy" <<<"${GENS}"; then
echo "Generating deepcopy 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}"/{}
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}"
fi
go run ./vendor/sigs.k8s.io/controller-tools/cmd/controller-gen/main.go object:headerFile=./hack/boilerplate.go.txt paths=./staging/src/kubesphere.io/api/"${PKG}"
else
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
go run ./vendor/sigs.k8s.io/controller-tools/cmd/controller-gen/main.go object:headerFile=./hack/boilerplate.go.txt paths=./staging/src/kubesphere.io/api/"${PKG}" rbac:roleName=controller-perms "${CRD_OPTIONS}" output:crd:artifacts:config=config/ks-core/crds
fi
done