mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-07 11:13:48 +00:00
Merge pull request #116281 from thockin/codegen_subproject_chdir
Codegen: subproject cleanups and chdir
This commit is contained in:
commit
ad85a92dd4
@ -35,7 +35,7 @@ UPDATE_API_KNOWN_VIOLATIONS="${UPDATE_API_KNOWN_VIOLATIONS:-}"
|
||||
|
||||
OUT_DIR="_output"
|
||||
PRJ_SRC_PATH="k8s.io/kubernetes"
|
||||
BOILERPLATE_FILENAME="vendor/k8s.io/code-generator/hack/boilerplate.go.txt"
|
||||
BOILERPLATE_FILENAME="hack/boilerplate/boilerplate.generatego.txt"
|
||||
APPLYCONFIG_PKG="k8s.io/client-go/applyconfigurations"
|
||||
|
||||
# Any time we call sort, we want it in the same locale.
|
||||
@ -885,21 +885,31 @@ function codegen::informers() {
|
||||
fi
|
||||
}
|
||||
|
||||
function indent() {
|
||||
while read -r X; do
|
||||
echo " ${X}"
|
||||
done
|
||||
}
|
||||
|
||||
function codegen::subprojects() {
|
||||
# Call generation on sub-projects.
|
||||
# TODO(thockin): make these take a list of codegens and flags
|
||||
local subs=(
|
||||
vendor/k8s.io/code-generator/hack/update-codegen.sh
|
||||
vendor/k8s.io/kube-aggregator/hack/update-codegen.sh
|
||||
vendor/k8s.io/sample-apiserver/hack/update-codegen.sh
|
||||
vendor/k8s.io/sample-controller/hack/update-codegen.sh
|
||||
vendor/k8s.io/apiextensions-apiserver/hack/update-codegen.sh
|
||||
vendor/k8s.io/metrics/hack/update-codegen.sh
|
||||
vendor/k8s.io/apiextensions-apiserver/examples/client-go/hack/update-codegen.sh
|
||||
vendor/k8s.io/code-generator/examples
|
||||
vendor/k8s.io/kube-aggregator
|
||||
vendor/k8s.io/sample-apiserver
|
||||
vendor/k8s.io/sample-controller
|
||||
vendor/k8s.io/apiextensions-apiserver
|
||||
vendor/k8s.io/metrics
|
||||
vendor/k8s.io/apiextensions-apiserver/examples/client-go
|
||||
)
|
||||
|
||||
for s in "${subs[@]}"; do
|
||||
CODEGEN_PKG=./vendor/k8s.io/code-generator "$s"
|
||||
local codegen
|
||||
codegen="$(pwd)/vendor/k8s.io/code-generator"
|
||||
for sub in "${subs[@]}"; do
|
||||
kube::log::status "Generating code for subproject ${sub}"
|
||||
pushd "${sub}" >/dev/null
|
||||
CODEGEN_PKG="${codegen}" ./hack/update-codegen.sh > >(indent) 2> >(indent >&2)
|
||||
popd >/dev/null
|
||||
done
|
||||
}
|
||||
|
||||
|
@ -18,34 +18,36 @@ set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
SCRIPT_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
|
||||
SCRIPT_DIR="$(dirname "${BASH_SOURCE[0]}")"
|
||||
SCRIPT_ROOT="${SCRIPT_DIR}/.."
|
||||
CODEGEN_PKG="${CODEGEN_PKG:-"${SCRIPT_ROOT}/.."}"
|
||||
|
||||
# generate the code with:
|
||||
# - --output-base because this script should also be able to run inside the vendor dir of
|
||||
# k8s.io/kubernetes. The output-base is needed for the generators to output into the vendor dir
|
||||
# instead of the $GOPATH directly. For normal projects this can be dropped.
|
||||
"${SCRIPT_ROOT}/generate-internal-groups.sh" "client,conversion,deepcopy,defaulter,informer,lister,openapi" \
|
||||
"${CODEGEN_PKG}/generate-internal-groups.sh" "client,conversion,deepcopy,defaulter,informer,lister,openapi" \
|
||||
k8s.io/code-generator/examples/apiserver \
|
||||
k8s.io/code-generator/examples/apiserver/apis \
|
||||
k8s.io/code-generator/examples/apiserver/apis \
|
||||
"example:v1 example2:v1 example3.io:v1" \
|
||||
--output-base "$(dirname "${BASH_SOURCE[0]}")/../../.." \
|
||||
--go-header-file "${SCRIPT_ROOT}/hack/boilerplate.go.txt"
|
||||
"${SCRIPT_ROOT}/generate-groups.sh" "applyconfiguration,client,deepcopy,defaulter,informer,lister" \
|
||||
--output-base "${SCRIPT_DIR}/../../../.." \
|
||||
--go-header-file "${SCRIPT_DIR}/boilerplate.go.txt"
|
||||
"${CODEGEN_PKG}/generate-groups.sh" "applyconfiguration,client,deepcopy,defaulter,informer,lister" \
|
||||
k8s.io/code-generator/examples/crd \
|
||||
k8s.io/code-generator/examples/crd/apis \
|
||||
"example:v1 example2:v1" \
|
||||
--output-base "$(dirname "${BASH_SOURCE[0]}")/../../.." \
|
||||
--go-header-file "${SCRIPT_ROOT}/hack/boilerplate.go.txt"
|
||||
"${SCRIPT_ROOT}/generate-groups.sh" "applyconfiguration,client,deepcopy,defaulter,informer,lister" \
|
||||
--output-base "${SCRIPT_DIR}/../../../.." \
|
||||
--go-header-file "${SCRIPT_DIR}/boilerplate.go.txt"
|
||||
"${CODEGEN_PKG}/generate-groups.sh" "applyconfiguration,client,deepcopy,defaulter,informer,lister" \
|
||||
k8s.io/code-generator/examples/MixedCase \
|
||||
k8s.io/code-generator/examples/MixedCase/apis \
|
||||
"example:v1" \
|
||||
--output-base "$(dirname "${BASH_SOURCE[0]}")/../../.." \
|
||||
--go-header-file "${SCRIPT_ROOT}/hack/boilerplate.go.txt"
|
||||
"${SCRIPT_ROOT}/generate-groups.sh" "applyconfiguration,client,deepcopy,defaulter,informer,lister" \
|
||||
--output-base "${SCRIPT_DIR}/../../../.." \
|
||||
--go-header-file "${SCRIPT_DIR}/boilerplate.go.txt"
|
||||
"${CODEGEN_PKG}/generate-groups.sh" "applyconfiguration,client,deepcopy,defaulter,informer,lister" \
|
||||
k8s.io/code-generator/examples/HyphenGroup \
|
||||
k8s.io/code-generator/examples/HyphenGroup/apis \
|
||||
"example:v1" \
|
||||
--output-base "$(dirname "${BASH_SOURCE[0]}")/../../.." \
|
||||
--go-header-file "${SCRIPT_ROOT}/hack/boilerplate.go.txt"
|
||||
--output-base "${SCRIPT_DIR}/../../../.." \
|
||||
--go-header-file "${SCRIPT_DIR}/boilerplate.go.txt"
|
@ -18,14 +18,12 @@ set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
SCRIPT_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
|
||||
|
||||
DIFFROOT="${SCRIPT_ROOT}/examples"
|
||||
TMP_DIFFROOT="${SCRIPT_ROOT}/_tmp/examples"
|
||||
_tmp="${SCRIPT_ROOT}/_tmp"
|
||||
SCRIPT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd -P)"
|
||||
DIFFROOT="${SCRIPT_ROOT}"
|
||||
TMP_DIFFROOT="$(mktemp -d -t "$(basename "$0").XXXXXX")"
|
||||
|
||||
cleanup() {
|
||||
rm -rf "${_tmp}"
|
||||
rm -rf "${TMP_DIFFROOT}"
|
||||
}
|
||||
trap "cleanup" EXIT SIGINT
|
||||
|
||||
@ -38,9 +36,7 @@ cp -a "${DIFFROOT}"/* "${TMP_DIFFROOT}"
|
||||
echo "diffing ${DIFFROOT} against freshly generated codegen"
|
||||
ret=0
|
||||
diff -Naupr "${DIFFROOT}" "${TMP_DIFFROOT}" || ret=$?
|
||||
cp -a "${TMP_DIFFROOT}"/* "${DIFFROOT}"
|
||||
if [[ $ret -eq 0 ]]
|
||||
then
|
||||
if [[ $ret -eq 0 ]]; then
|
||||
echo "${DIFFROOT} up to date."
|
||||
else
|
||||
echo "${DIFFROOT} is out of date. Please run hack/update-codegen.sh"
|
||||
@ -49,7 +45,7 @@ fi
|
||||
|
||||
# smoke test
|
||||
echo "Smoke testing examples by compiling..."
|
||||
pushd "./${SCRIPT_ROOT}/examples"
|
||||
pushd "${SCRIPT_ROOT}"
|
||||
go build "k8s.io/code-generator/examples/crd/..."
|
||||
go build "k8s.io/code-generator/examples/apiserver/..."
|
||||
go build "k8s.io/code-generator/examples/MixedCase/..."
|
Loading…
Reference in New Issue
Block a user