Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using common code generation scripts #162

Merged
merged 1 commit into from
Feb 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 15 additions & 17 deletions hack/generate-code
Original file line number Diff line number Diff line change
Expand Up @@ -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"