Skip to content

Commit

Permalink
Updated kube-codegen.
Browse files Browse the repository at this point in the history
  • Loading branch information
mbobrovskyi committed Jun 12, 2024
1 parent 380effa commit 5eac066
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 26 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ update-helm: manifests yq
.PHONY: generate
generate: gomod-download controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations and client-go libraries.
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./apis/..."
./hack/update-codegen.sh $(GO_CMD)
TOOLS_DIR=${TOOLS_DIR} ./hack/update-codegen.sh $(GO_CMD)

.PHONY: fmt
fmt: ## Run go fmt against code.
Expand Down
2 changes: 1 addition & 1 deletion hack/internal/tools/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ require (
k8s.io/client-go v0.30.0 // indirect
k8s.io/gengo/v2 v2.0.0-20240228010128-51d4e06bde70 // indirect
k8s.io/klog/v2 v2.120.1 // indirect
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect
k8s.io/kube-openapi v0.0.0-20240521193020-835d969ad83a // indirect
k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/kustomize/api v0.13.5-0.20230601165947-6ce0bf390ce3 // indirect
Expand Down
4 changes: 2 additions & 2 deletions hack/internal/tools/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -466,8 +466,8 @@ k8s.io/gengo/v2 v2.0.0-20240228010128-51d4e06bde70 h1:NGrVE502P0s0/1hudf8zjgwki1
k8s.io/gengo/v2 v2.0.0-20240228010128-51d4e06bde70/go.mod h1:VH3AT8AaQOqiGjMF9p0/IM1Dj+82ZwjfxUP1IxaHE+8=
k8s.io/klog/v2 v2.120.1 h1:QXU6cPEOIslTGvZaXvFWiP9VKyeet3sawzTOvdXb4Vw=
k8s.io/klog/v2 v2.120.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE=
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 h1:BZqlfIlq5YbRMFko6/PM7FjZpUb45WallggurYhKGag=
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340/go.mod h1:yD4MZYeKMBwQKVht279WycxKyM84kkAx2DPrTXaeb98=
k8s.io/kube-openapi v0.0.0-20240521193020-835d969ad83a h1:zD1uj3Jf+mD4zmA7W+goE5TxDkI7OGJjBNBzq5fJtLA=
k8s.io/kube-openapi v0.0.0-20240521193020-835d969ad83a/go.mod h1:UxDHUPsUwTOOxSU+oXURfFBcAS6JwiRXTYqYwfuGowc=
k8s.io/utils v0.0.0-20230726121419-3b25d923346b h1:sgn3ZU783SCgtaSJjpcVVlRqd6GSnlTLKgpAAttJvpI=
k8s.io/utils v0.0.0-20230726121419-3b25d923346b/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
sigs.k8s.io/controller-runtime/tools/setup-envtest v0.0.0-20240522175850-2e9781e9fc60 h1:ihaeBTCFuEYPL1T1/FqAavDY7z5UcKSnWpnb+I3DYeM=
Expand Down
35 changes: 13 additions & 22 deletions hack/update-codegen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,40 +20,31 @@ set -o pipefail

GO_CMD=${1:-go}
KUEUE_ROOT=$(realpath $(dirname ${BASH_SOURCE[0]})/..)
CODEGEN_PKG=$($GO_CMD list -m -f "{{.Dir}}" k8s.io/code-generator)

cd $(dirname ${BASH_SOURCE[0]})/..
KUEUE_PKG="sigs.k8s.io/kueue"
CODEGEN_PKG=$(cd $TOOLS_DIR; go mod download; $GO_CMD list -m -f "{{.Dir}}" k8s.io/code-generator)

source "${CODEGEN_PKG}/kube_codegen.sh"

# TODO: remove the workaround when the issue is solved in the code-generator
# (https://github.com/kubernetes/code-generator/issues/165).
# Here, we create the soft link named "sigs.k8s.io" to the parent directory of
# Kueue to ensure the layout required by the kube_codegen.sh script.
ln -s .. sigs.k8s.io
trap "rm sigs.k8s.io" EXIT

# Generating conversion and defaults functions
kube::codegen::gen_helpers \
--input-pkg-root sigs.k8s.io/kueue/apis \
--output-base "${KUEUE_ROOT}" \
--boilerplate ${KUEUE_ROOT}/hack/boilerplate.go.txt
--boilerplate ${KUEUE_ROOT}/hack/boilerplate.go.txt \
"${KUEUE_ROOT}/apis"

# Generating OpenAPI for Kueue API extensions
kube::codegen::gen_openapi \
--input-pkg-root sigs.k8s.io/kueue/apis/visibility \
--output-pkg-root sigs.k8s.io/kueue/apis/visibility/v1alpha1 \
--output-base "${KUEUE_ROOT}" \
--boilerplate "${KUEUE_ROOT}/hack/boilerplate.go.txt" \
--output-dir "${KUEUE_ROOT}/client-go" \
--output-pkg "${KUEUE_PKG}/client-go" \
--update-report \
--boilerplate "${KUEUE_ROOT}/hack/boilerplate.go.txt"
"${KUEUE_ROOT}/apis"

kube::codegen::gen_client \
--input-pkg-root sigs.k8s.io/kueue/apis \
--output-pkg-root sigs.k8s.io/kueue/client-go \
--output-base "${KUEUE_ROOT}" \
--boilerplate ${KUEUE_ROOT}/hack/boilerplate.go.txt \
--boilerplate "${KUEUE_ROOT}/hack/boilerplate.go.txt" \
--output-dir "${KUEUE_ROOT}/client-go" \
--output-pkg "${KUEUE_PKG}/client-go" \
--with-watch \
--with-applyconfig
--with-applyconfig \
"${KUEUE_ROOT}/apis"

# 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 5eac066

Please sign in to comment.