Skip to content

Commit

Permalink
Fix update-codegen.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksandra-malinowska committed Aug 21, 2024
1 parent 5ec21a1 commit 6db8d2d
Showing 1 changed file with 27 additions and 16 deletions.
43 changes: 27 additions & 16 deletions cluster-autoscaler/hack/update-codegen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,30 @@ set -o errexit
set -o nounset
set -o pipefail

SCRIPT_ROOT=$(realpath $(dirname "${BASH_SOURCE[0]}"))/..
CODEGEN_PKG="../vendor/k8s.io/code-generator"
pushd "${SCRIPT_ROOT}/apis"

chmod +x "${CODEGEN_PKG}"/generate-groups.sh
chmod +x "${CODEGEN_PKG}"/generate-internal-groups.sh

bash "${CODEGEN_PKG}"/generate-groups.sh "applyconfiguration,client,deepcopy,informer,lister" \
k8s.io/autoscaler/cluster-autoscaler/apis/provisioningrequest/client \
k8s.io/autoscaler/cluster-autoscaler/apis/provisioningrequest \
autoscaling.x-k8s.io:v1beta1 \
--go-header-file "${SCRIPT_ROOT}"/../hack/boilerplate/boilerplate.generatego.txt

chmod -x "${CODEGEN_PKG}"/generate-groups.sh
chmod -x "${CODEGEN_PKG}"/generate-internal-groups.sh
popd
GO_CMD=${1:-go}
CURRENT_DIR=$(dirname "${BASH_SOURCE[0]}")
REPO_ROOT="$(git rev-parse --show-toplevel)"
CODEGEN_PKG=$($GO_CMD list -m -mod=readonly -f "{{.Dir}}" k8s.io/code-generator)
cd "${CURRENT_DIR}/.."

# shellcheck source=/dev/null
source "${CODEGEN_PKG}/kube_codegen.sh"

kube::codegen::gen_helpers \
--boilerplate "${REPO_ROOT}/hack/boilerplate/boilerplate.generatego.txt" \
"${REPO_ROOT}/cluster-autoscaler/apis/provisioningrequest"

echo "Ran gen helpers, moving on to generating client code..."

kube::codegen::gen_client \
--output-pkg k8s.io/autoscaler/cluster-autoscaler/apis/provisioningrequest/client \
--output-dir "${REPO_ROOT}/cluster-autoscaler/apis/provisioningrequest/client" \
--boilerplate "${REPO_ROOT}/hack/boilerplate/boilerplate.generatego.txt" \
--with-watch \
--with-applyconfig \
"${REPO_ROOT}/cluster-autoscaler/apis/provisioningrequest"

echo "Generated client code, running `go mod tidy`..."

# We need to clean up the go.mod file since code-generator adds temporary library to the go.mod file.
"${GO_CMD}" mod tidy

0 comments on commit 6db8d2d

Please sign in to comment.