mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-11 13:02:14 +00:00
Codegen subprojects: consolidate generate-*groups
They both still exist, with the same API as before, but now generate-groups calls generate-internal-groups, which is a superset.
This commit is contained in:
parent
95e614b371
commit
5f7345deaa
@ -25,7 +25,7 @@ if [ "$#" -lt 4 ] || [ "${1}" == "--help" ]; then
|
|||||||
cat <<EOF
|
cat <<EOF
|
||||||
Usage: $(basename "$0") <generators> <output-package> <apis-package> <groups-versions> ...
|
Usage: $(basename "$0") <generators> <output-package> <apis-package> <groups-versions> ...
|
||||||
|
|
||||||
<generators> the generators comma separated to run (deepcopy, defaulter,applyconfiguration,client,lister,informer).
|
<generators> the generators comma separated to run (deepcopy,defaulter,applyconfiguration,client,lister,informer).
|
||||||
<output-package> the output package name (e.g. github.com/example/project/pkg/generated).
|
<output-package> the output package name (e.g. github.com/example/project/pkg/generated).
|
||||||
<apis-package> the external types dir (e.g. github.com/example/api or github.com/example/project/pkg/apis).
|
<apis-package> the external types dir (e.g. github.com/example/api or github.com/example/project/pkg/apis).
|
||||||
<groups-versions> the groups and their versions in the format "groupA:v1,v2 groupB:v1 groupC:v2", relative
|
<groups-versions> the groups and their versions in the format "groupA:v1,v2 groupB:v1 groupC:v2", relative
|
||||||
@ -58,81 +58,5 @@ if [ "${GENS}" = "all" ] || grep -qw "all" <<<"${GENS}"; then
|
|||||||
GENS="${ALL}"
|
GENS="${ALL}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
(
|
INT_APIS_PKG=""
|
||||||
# To support running this script from anywhere, first cd into this directory,
|
exec "$(dirname "${BASH_SOURCE[0]}")/generate-internal-groups.sh" "${GENS}" "${OUTPUT_PKG}" "${INT_APIS_PKG}" "${APIS_PKG}" "${GROUPS_WITH_VERSIONS}" "$@"
|
||||||
# and then install with forced module mode on and fully qualified name.
|
|
||||||
cd "$(dirname "${0}")"
|
|
||||||
GO111MODULE=on go install k8s.io/code-generator/cmd/{applyconfiguration-gen,client-gen,lister-gen,informer-gen,deepcopy-gen,defaulter-gen}
|
|
||||||
)
|
|
||||||
# Go installs the above commands to get installed in $GOBIN if defined, and $GOPATH/bin otherwise:
|
|
||||||
GOBIN="$(go env GOBIN)"
|
|
||||||
gobin="${GOBIN:-$(go env GOPATH)/bin}"
|
|
||||||
|
|
||||||
function codegen::join() { local IFS="$1"; shift; echo "$*"; }
|
|
||||||
|
|
||||||
# enumerate group versions
|
|
||||||
FQ_APIS=() # e.g. k8s.io/api/apps/v1
|
|
||||||
for GVs in ${GROUPS_WITH_VERSIONS}; do
|
|
||||||
IFS=: read -r G Vs <<<"${GVs}"
|
|
||||||
|
|
||||||
# enumerate versions
|
|
||||||
for V in ${Vs//,/ }; do
|
|
||||||
FQ_APIS+=("${APIS_PKG}/${G}/${V}")
|
|
||||||
done
|
|
||||||
done
|
|
||||||
|
|
||||||
if grep -qw "deepcopy" <<<"${GENS}"; then
|
|
||||||
echo "Generating deepcopy funcs"
|
|
||||||
"${gobin}/deepcopy-gen" \
|
|
||||||
--input-dirs "$(codegen::join , "${FQ_APIS[@]}")" \
|
|
||||||
-O zz_generated.deepcopy \
|
|
||||||
"$@"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if grep -qw "defaulter" <<<"${GENS}"; then
|
|
||||||
echo "Generating defaulters"
|
|
||||||
"${gobin}/defaulter-gen" \
|
|
||||||
--input-dirs "$(codegen::join , "${FQ_APIS[@]}")" \
|
|
||||||
-O zz_generated.defaults \
|
|
||||||
"$@"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if grep -qw "applyconfiguration" <<<"${GENS}"; then
|
|
||||||
echo "Generating apply configuration for ${GROUPS_WITH_VERSIONS} at ${OUTPUT_PKG}/${APPLYCONFIGURATION_PKG_NAME:-applyconfiguration}"
|
|
||||||
"${gobin}/applyconfiguration-gen" \
|
|
||||||
--input-dirs "$(codegen::join , "${FQ_APIS[@]}")" \
|
|
||||||
--output-package "${OUTPUT_PKG}/${APPLYCONFIGURATION_PKG_NAME:-applyconfiguration}" \
|
|
||||||
"$@"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if grep -qw "client" <<<"${GENS}"; then
|
|
||||||
echo "Generating clientset for ${GROUPS_WITH_VERSIONS} at ${OUTPUT_PKG}/${CLIENTSET_PKG_NAME:-clientset}"
|
|
||||||
if grep -qw "applyconfiguration" <<<"${GENS}"; then
|
|
||||||
APPLY_CONFIGURATION_PACKAGE="${OUTPUT_PKG}/${APPLYCONFIGURATION_PKG_NAME:-applyconfiguration}"
|
|
||||||
fi
|
|
||||||
"${gobin}/client-gen" \
|
|
||||||
--clientset-name "${CLIENTSET_NAME_VERSIONED:-versioned}" \
|
|
||||||
--input-base "" \
|
|
||||||
--input "$(codegen::join , "${FQ_APIS[@]}")" \
|
|
||||||
--output-package "${OUTPUT_PKG}/${CLIENTSET_PKG_NAME:-clientset}" \
|
|
||||||
--apply-configuration-package "${APPLY_CONFIGURATION_PACKAGE:-}" \
|
|
||||||
"$@"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if grep -qw "lister" <<<"${GENS}"; then
|
|
||||||
echo "Generating listers for ${GROUPS_WITH_VERSIONS} at ${OUTPUT_PKG}/listers"
|
|
||||||
"${gobin}/lister-gen" \
|
|
||||||
--input-dirs "$(codegen::join , "${FQ_APIS[@]}")" \
|
|
||||||
--output-package "${OUTPUT_PKG}/listers" \
|
|
||||||
"$@"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if grep -qw "informer" <<<"${GENS}"; then
|
|
||||||
echo "Generating informers for ${GROUPS_WITH_VERSIONS} at ${OUTPUT_PKG}/informers"
|
|
||||||
"${gobin}/informer-gen" \
|
|
||||||
--input-dirs "$(codegen::join , "${FQ_APIS[@]}")" \
|
|
||||||
--versioned-clientset-package "${OUTPUT_PKG}/${CLIENTSET_PKG_NAME:-clientset}/${CLIENTSET_NAME_VERSIONED:-versioned}" \
|
|
||||||
--listers-package "${OUTPUT_PKG}/listers" \
|
|
||||||
--output-package "${OUTPUT_PKG}/informers" \
|
|
||||||
"$@"
|
|
||||||
fi
|
|
||||||
|
@ -25,9 +25,9 @@ if [ "$#" -lt 5 ] || [ "${1}" == "--help" ]; then
|
|||||||
cat <<EOF
|
cat <<EOF
|
||||||
Usage: $(basename "$0") <generators> <output-package> <internal-apis-package> <extensiona-apis-package> <groups-versions> ...
|
Usage: $(basename "$0") <generators> <output-package> <internal-apis-package> <extensiona-apis-package> <groups-versions> ...
|
||||||
|
|
||||||
<generators> the generators comma separated to run (deepcopy,defaulter,conversion,client,lister,informer,openapi).
|
<generators> the generators comma separated to run (applyconfiguration,client,conversion,deepcopy,defaulter,informer,lister,openapi).
|
||||||
<output-package> the output package name (e.g. github.com/example/project/pkg/generated).
|
<output-package> the output package name (e.g. github.com/example/project/pkg/generated).
|
||||||
<int-apis-package> the internal types dir (e.g. github.com/example/project/pkg/apis).
|
<int-apis-package> the internal types dir (e.g. github.com/example/project/pkg/apis) or "" if none.
|
||||||
<ext-apis-package> the external types dir (e.g. github.com/example/project/pkg/apis or githubcom/example/apis).
|
<ext-apis-package> the external types dir (e.g. github.com/example/project/pkg/apis or githubcom/example/apis).
|
||||||
<groups-versions> the groups and their versions in the format "groupA:v1,v2 groupB:v1 groupC:v2", relative
|
<groups-versions> the groups and their versions in the format "groupA:v1,v2 groupB:v1 groupC:v2", relative
|
||||||
to <api-package>.
|
to <api-package>.
|
||||||
@ -64,7 +64,19 @@ fi
|
|||||||
# To support running this script from anywhere, first cd into this directory,
|
# To support running this script from anywhere, first cd into this directory,
|
||||||
# and then install with forced module mode on and fully qualified name.
|
# and then install with forced module mode on and fully qualified name.
|
||||||
cd "$(dirname "${0}")"
|
cd "$(dirname "${0}")"
|
||||||
GO111MODULE=on go install k8s.io/code-generator/cmd/{defaulter-gen,conversion-gen,client-gen,lister-gen,informer-gen,deepcopy-gen,openapi-gen}
|
BINS=(
|
||||||
|
applyconfiguration-gen
|
||||||
|
client-gen
|
||||||
|
conversion-gen
|
||||||
|
deepcopy-gen
|
||||||
|
defaulter-gen
|
||||||
|
informer-gen
|
||||||
|
lister-gen
|
||||||
|
openapi-gen
|
||||||
|
)
|
||||||
|
# Compile all the tools at once - it's slightly faster but also just simpler.
|
||||||
|
# shellcheck disable=2046 # printf word-splitting is intentional
|
||||||
|
GO111MODULE=on go install $(printf "k8s.io/code-generator/cmd/%s " "${BINS[@]}")
|
||||||
)
|
)
|
||||||
|
|
||||||
# Go installs the above commands to get installed in $GOBIN if defined, and $GOPATH/bin otherwise:
|
# Go installs the above commands to get installed in $GOBIN if defined, and $GOPATH/bin otherwise:
|
||||||
@ -114,6 +126,15 @@ if grep -qw "conversion" <<<"${GENS}"; then
|
|||||||
"$@"
|
"$@"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if grep -qw "applyconfiguration" <<<"${GENS}"; then
|
||||||
|
echo "Generating apply configuration for ${GROUPS_WITH_VERSIONS} at ${OUTPUT_PKG}/${APPLYCONFIGURATION_PKG_NAME:-applyconfiguration}"
|
||||||
|
APPLY_CONFIGURATION_PACKAGE="${OUTPUT_PKG}/${APPLYCONFIGURATION_PKG_NAME:-applyconfiguration}"
|
||||||
|
"${gobin}/applyconfiguration-gen" \
|
||||||
|
--input-dirs "$(codegen::join , "${EXT_FQ_APIS[@]}")" \
|
||||||
|
--output-package "${APPLY_CONFIGURATION_PACKAGE}" \
|
||||||
|
"$@"
|
||||||
|
fi
|
||||||
|
|
||||||
if grep -qw "client" <<<"${GENS}"; then
|
if grep -qw "client" <<<"${GENS}"; then
|
||||||
echo "Generating clientset for ${GROUPS_WITH_VERSIONS} at ${OUTPUT_PKG}/${CLIENTSET_PKG_NAME:-clientset}"
|
echo "Generating clientset for ${GROUPS_WITH_VERSIONS} at ${OUTPUT_PKG}/${CLIENTSET_PKG_NAME:-clientset}"
|
||||||
"${gobin}/client-gen" \
|
"${gobin}/client-gen" \
|
||||||
@ -121,6 +142,7 @@ if grep -qw "client" <<<"${GENS}"; then
|
|||||||
--input-base "" \
|
--input-base "" \
|
||||||
--input "$(codegen::join , "${EXT_FQ_APIS[@]}")" \
|
--input "$(codegen::join , "${EXT_FQ_APIS[@]}")" \
|
||||||
--output-package "${OUTPUT_PKG}/${CLIENTSET_PKG_NAME:-clientset}" \
|
--output-package "${OUTPUT_PKG}/${CLIENTSET_PKG_NAME:-clientset}" \
|
||||||
|
--apply-configuration-package "${APPLY_CONFIGURATION_PACKAGE:-}" \
|
||||||
"$@"
|
"$@"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user