sigs.k8s.io/kueue@v0.6.2/hack/update-codegen.sh (about) 1 #!/usr/bin/env bash 2 3 # Copyright 2023 The Kubernetes Authors. 4 # 5 # Licensed under the Apache License, Version 2.0 (the "License"); 6 # you may not use this file except in compliance with the License. 7 # You may obtain a copy of the License at 8 # 9 # http://www.apache.org/licenses/LICENSE-2.0 10 # 11 # Unless required by applicable law or agreed to in writing, software 12 # distributed under the License is distributed on an "AS IS" BASIS, 13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 # See the License for the specific language governing permissions and 15 # limitations under the License. 16 17 set -o errexit 18 set -o nounset 19 set -o pipefail 20 21 GO_CMD=${1:-go} 22 KUEUE_ROOT=$(realpath $(dirname ${BASH_SOURCE[0]})/..) 23 CODEGEN_PKG=$($GO_CMD list -m -f "{{.Dir}}" k8s.io/code-generator) 24 25 cd $(dirname ${BASH_SOURCE[0]})/.. 26 27 source "${CODEGEN_PKG}/kube_codegen.sh" 28 29 # TODO: remove the workaround when the issue is solved in the code-generator 30 # (https://github.com/kubernetes/code-generator/issues/165). 31 # Here, we create the soft link named "sigs.k8s.io" to the parent directory of 32 # Kueue to ensure the layout required by the kube_codegen.sh script. 33 ln -s .. sigs.k8s.io 34 trap "rm sigs.k8s.io" EXIT 35 36 # Generating conversion and defaults functions 37 kube::codegen::gen_helpers \ 38 --input-pkg-root sigs.k8s.io/kueue/apis \ 39 --output-base "${KUEUE_ROOT}" \ 40 --boilerplate ${KUEUE_ROOT}/hack/boilerplate.go.txt 41 42 # Generating OpenAPI for Kueue API extensions 43 kube::codegen::gen_openapi \ 44 --input-pkg-root sigs.k8s.io/kueue/apis/visibility \ 45 --output-pkg-root sigs.k8s.io/kueue/apis/visibility/v1alpha1 \ 46 --output-base "${KUEUE_ROOT}" \ 47 --update-report \ 48 --boilerplate "${KUEUE_ROOT}/hack/boilerplate.go.txt" 49 50 kube::codegen::gen_client \ 51 --input-pkg-root sigs.k8s.io/kueue/apis \ 52 --output-pkg-root sigs.k8s.io/kueue/client-go \ 53 --output-base "${KUEUE_ROOT}" \ 54 --boilerplate ${KUEUE_ROOT}/hack/boilerplate.go.txt \ 55 --with-watch \ 56 --with-applyconfig 57 58 # We need to clean up the go.mod file since code-generator adds temporary library to the go.mod file. 59 "${GO_CMD}" mod tidy