Use controller-gen to generate deepcopy code, and replace the deepcopy-gen tags with the kubebuilder tags. Signed-off-by: hongzhouzi <hongzhouzi@kubesphere.io> Signed-off-by: hongzhouzi <hongzhouzi@kubesphere.io>
36 lines
1.7 KiB
Bash
Executable File
36 lines
1.7 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
set -ex
|
|
|
|
CRD_OPTIONS="$1"
|
|
PKGS="$2"
|
|
GENS="$3"
|
|
IFS=" " read -r -a PKGS <<< "${PKGS}"
|
|
|
|
KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
|
|
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
|
|
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
|
|
fi
|
|
done
|