diff --git a/Makefile b/Makefile index 7784771be9..8f09d5dc45 100644 --- a/Makefile +++ b/Makefile @@ -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. diff --git a/hack/internal/tools/go.mod b/hack/internal/tools/go.mod index 5384d86f56..0c4a4c3f78 100644 --- a/hack/internal/tools/go.mod +++ b/hack/internal/tools/go.mod @@ -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 diff --git a/hack/internal/tools/go.sum b/hack/internal/tools/go.sum index c1869f7da4..30d3fbc784 100644 --- a/hack/internal/tools/go.sum +++ b/hack/internal/tools/go.sum @@ -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= diff --git a/hack/update-codegen.sh b/hack/update-codegen.sh index 3d6dbdfc21..25a7413b5e 100755 --- a/hack/update-codegen.sh +++ b/hack/update-codegen.sh @@ -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