From 9466d8aa2af0ccbca41c802dd5ddaa7d54f9a85e Mon Sep 17 00:00:00 2001 From: Martin Weindel Date: Tue, 13 Feb 2024 14:05:44 +0100 Subject: [PATCH] using common code generation scripts --- hack/generate-code | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/hack/generate-code b/hack/generate-code index c93d789c..e9a8d1d1 100755 --- a/hack/generate-code +++ b/hack/generate-code @@ -6,30 +6,28 @@ set -e -rm -f ${GOPATH}/bin/*-gen - SOURCE_PATH="$(readlink -f "$(dirname ${0})/..")" rm -rf "$SOURCE_PATH/pkg/client/cert" # setup virtual GOPATH source "$CONTROLLER_MANAGER_LIB_HACK_DIR"/vgopath-setup.sh -trap 'rm -rf "$VIRTUAL_GOPATH"; rm -rf $REPO_ROOT/vendor' EXIT -go mod vendor -CODEGEN_PKG=${CODEGEN_PKG:-$(cd "${SOURCE_PATH}"; ls -d -1 ./vendor/k8s.io/code-generator 2>/dev/null || echo ../code-generator)} -source "${CODEGEN_PKG}/kube_codegen.sh" +CODE_GEN_DIR=$(go list -m -f '{{.Dir}}' k8s.io/code-generator) + +rm -f ${GOPATH}/bin/*-gen -PKGPATH=github.com/gardener/cert-management +# We need to explicitly pass GO111MODULE=off to k8s.io/code-generator as it is significantly slower otherwise, +# see https://github.com/kubernetes/code-generator/issues/100. +export GO111MODULE=off -kube::codegen::gen_helpers \ - --input-pkg-root $PKGPATH/pkg/apis \ - --output-base "${SOURCE_PATH}/../../.." \ - --boilerplate "${SOURCE_PATH}/hack/LICENSE_BOILERPLATE.txt" +rm -rf "${SOURCE_PATH}/pkg/client/cert" +PROJECT_ROOT=$(dirname $0)/.. -kube::codegen::gen_client \ - --with-watch \ - --input-pkg-root $PKGPATH/pkg/apis \ - --output-pkg-root $PKGPATH/pkg/client/cert \ - --output-base "${SOURCE_PATH}/../../.." \ - --boilerplate "${SOURCE_PATH}/hack/LICENSE_BOILERPLATE.txt" +bash "${CODE_GEN_DIR}"/generate-internal-groups.sh \ + "deepcopy,client,informer,lister" \ + github.com/gardener/cert-management/pkg/client/cert \ + "" \ + github.com/gardener/cert-management/pkg/apis \ + "cert:v1alpha1" \ + --go-header-file "${SOURCE_PATH}/hack/LICENSE_BOILERPLATE.txt"