Codegen subprojects: deprecate "all" in scripts

Replace "all" with the historical meaning of it in the generate-groups
scripts.
This commit is contained in:
Tim Hockin 2023-03-11 09:54:09 -08:00
parent a94ed5b8ac
commit 95e614b371
No known key found for this signature in database
2 changed files with 47 additions and 22 deletions

View File

@ -25,7 +25,7 @@ if [ "$#" -lt 4 ] || [ "${1}" == "--help" ]; then
cat <<EOF
Usage: $(basename "$0") <generators> <output-package> <apis-package> <groups-versions> ...
<generators> the generators comma separated to run (deepcopy, defaulter,applyconfiguration,client,lister,informer) or "all".
<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).
<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
@ -33,9 +33,12 @@ Usage: $(basename "$0") <generators> <output-package> <apis-package> <groups-ver
... arbitrary flags passed to all generator binaries.
Examples:
$(basename "$0") all github.com/example/project/pkg/client github.com/example/project/pkg/apis "foo:v1 bar:v1alpha1,v1beta1"
$(basename "$0") deepcopy,client github.com/example/project/pkg/client github.com/example/project/pkg/apis "foo:v1 bar:v1alpha1,v1beta1"
Example:
$(basename "$0") \
deepcopy,client \
github.com/example/project/pkg/client \
github.com/example/project/pkg/apis \
"foo:v1 bar:v1alpha1,v1beta1"
EOF
exit 0
fi
@ -46,6 +49,15 @@ APIS_PKG="$3"
GROUPS_WITH_VERSIONS="$4"
shift 4
if [ "${GENS}" = "all" ] || grep -qw "all" <<<"${GENS}"; then
ALL="applyconfiguration,client,deepcopy,informer,lister"
echo "WARNING: Specifying \"all\" as a generator is deprecated."
echo "WARNING: Please list the specific generators needed."
echo "WARNING: \"all\" is now an alias for \"${ALL}\""
echo
GENS="${ALL}"
fi
(
# To support running this script from anywhere, first cd into this directory,
# and then install with forced module mode on and fully qualified name.
@ -69,7 +81,7 @@ for GVs in ${GROUPS_WITH_VERSIONS}; do
done
done
if [ "${GENS}" = "all" ] || grep -qw "deepcopy" <<<"${GENS}"; then
if grep -qw "deepcopy" <<<"${GENS}"; then
echo "Generating deepcopy funcs"
"${gobin}/deepcopy-gen" \
--input-dirs "$(codegen::join , "${FQ_APIS[@]}")" \
@ -77,7 +89,7 @@ if [ "${GENS}" = "all" ] || grep -qw "deepcopy" <<<"${GENS}"; then
"$@"
fi
if [ "${GENS}" = "all" ] || grep -qw "defaulter" <<<"${GENS}"; then
if grep -qw "defaulter" <<<"${GENS}"; then
echo "Generating defaulters"
"${gobin}/defaulter-gen" \
--input-dirs "$(codegen::join , "${FQ_APIS[@]}")" \
@ -85,7 +97,7 @@ if [ "${GENS}" = "all" ] || grep -qw "defaulter" <<<"${GENS}"; then
"$@"
fi
if [ "${GENS}" = "all" ] || grep -qw "applyconfiguration" <<<"${GENS}"; then
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[@]}")" \
@ -93,9 +105,9 @@ if [ "${GENS}" = "all" ] || grep -qw "applyconfiguration" <<<"${GENS}"; then
"$@"
fi
if [ "${GENS}" = "all" ] || 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}"
if [ "${GENS}" = "all" ] || grep -qw "applyconfiguration" <<<"${GENS}"; then
if grep -qw "applyconfiguration" <<<"${GENS}"; then
APPLY_CONFIGURATION_PACKAGE="${OUTPUT_PKG}/${APPLYCONFIGURATION_PKG_NAME:-applyconfiguration}"
fi
"${gobin}/client-gen" \
@ -107,7 +119,7 @@ if [ "${GENS}" = "all" ] || grep -qw "client" <<<"${GENS}"; then
"$@"
fi
if [ "${GENS}" = "all" ] || grep -qw "lister" <<<"${GENS}"; then
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[@]}")" \
@ -115,7 +127,7 @@ if [ "${GENS}" = "all" ] || grep -qw "lister" <<<"${GENS}"; then
"$@"
fi
if [ "${GENS}" = "all" ] || grep -qw "informer" <<<"${GENS}"; then
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[@]}")" \

View File

@ -25,7 +25,7 @@ if [ "$#" -lt 5 ] || [ "${1}" == "--help" ]; then
cat <<EOF
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) or "all".
<generators> the generators comma separated to run (deepcopy,defaulter,conversion,client,lister,informer,openapi).
<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).
<ext-apis-package> the external types dir (e.g. github.com/example/project/pkg/apis or githubcom/example/apis).
@ -33,9 +33,13 @@ Usage: $(basename "$0") <generators> <output-package> <internal-apis-package> <e
to <api-package>.
... arbitrary flags passed to all generator binaries.
Examples:
$(basename "$0") all github.com/example/project/pkg/client github.com/example/project/pkg/apis github.com/example/project/pkg/apis "foo:v1 bar:v1alpha1,v1beta1"
$(basename "$0") deepcopy,defaulter,conversion github.com/example/project/pkg/client github.com/example/project/pkg/apis github.com/example/project/apis "foo:v1 bar:v1alpha1,v1beta1"
Example:
$(basename "$0") \
deepcopy,defaulter,conversion \
github.com/example/project/pkg/client \
github.com/example/project/pkg/apis \
github.com/example/project/apis \
"foo:v1 bar:v1alpha1,v1beta1"
EOF
exit 0
fi
@ -47,6 +51,15 @@ EXT_APIS_PKG="$4"
GROUPS_WITH_VERSIONS="$5"
shift 5
if [ "${GENS}" = "all" ] || grep -qw "all" <<<"${GENS}"; then
ALL="client,conversion,deepcopy,defaulter,informer,lister,openapi"
echo "WARNING: Specifying \"all\" as a generator is deprecated."
echo "WARNING: Please list the specific generators needed."
echo "WARNING: \"all\" is now an alias for \"${ALL}\""
echo
GENS="${ALL}"
fi
(
# To support running this script from anywhere, first cd into this directory,
# and then install with forced module mode on and fully qualified name.
@ -77,7 +90,7 @@ for GVs in ${GROUPS_WITH_VERSIONS}; do
done
done
if [ "${GENS}" = "all" ] || grep -qw "deepcopy" <<<"${GENS}"; then
if grep -qw "deepcopy" <<<"${GENS}"; then
echo "Generating deepcopy funcs"
"${gobin}/deepcopy-gen" \
--input-dirs "$(codegen::join , "${ALL_FQ_APIS[@]}")" \
@ -85,7 +98,7 @@ if [ "${GENS}" = "all" ] || grep -qw "deepcopy" <<<"${GENS}"; then
"$@"
fi
if [ "${GENS}" = "all" ] || grep -qw "defaulter" <<<"${GENS}"; then
if grep -qw "defaulter" <<<"${GENS}"; then
echo "Generating defaulters"
"${gobin}/defaulter-gen" \
--input-dirs "$(codegen::join , "${EXT_FQ_APIS[@]}")" \
@ -93,7 +106,7 @@ if [ "${GENS}" = "all" ] || grep -qw "defaulter" <<<"${GENS}"; then
"$@"
fi
if [ "${GENS}" = "all" ] || grep -qw "conversion" <<<"${GENS}"; then
if grep -qw "conversion" <<<"${GENS}"; then
echo "Generating conversions"
"${gobin}/conversion-gen" \
--input-dirs "$(codegen::join , "${ALL_FQ_APIS[@]}")" \
@ -101,7 +114,7 @@ if [ "${GENS}" = "all" ] || grep -qw "conversion" <<<"${GENS}"; then
"$@"
fi
if [ "${GENS}" = "all" ] || 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}"
"${gobin}/client-gen" \
--clientset-name "${CLIENTSET_NAME_VERSIONED:-versioned}" \
@ -111,7 +124,7 @@ if [ "${GENS}" = "all" ] || grep -qw "client" <<<"${GENS}"; then
"$@"
fi
if [ "${GENS}" = "all" ] || grep -qw "lister" <<<"${GENS}"; then
if grep -qw "lister" <<<"${GENS}"; then
echo "Generating listers for ${GROUPS_WITH_VERSIONS} at ${OUTPUT_PKG}/listers"
"${gobin}/lister-gen" \
--input-dirs "$(codegen::join , "${EXT_FQ_APIS[@]}")" \
@ -119,7 +132,7 @@ if [ "${GENS}" = "all" ] || grep -qw "lister" <<<"${GENS}"; then
"$@"
fi
if [ "${GENS}" = "all" ] || grep -qw "informer" <<<"${GENS}"; then
if grep -qw "informer" <<<"${GENS}"; then
echo "Generating informers for ${GROUPS_WITH_VERSIONS} at ${OUTPUT_PKG}/informers"
"${gobin}/informer-gen" \
--input-dirs "$(codegen::join , "${EXT_FQ_APIS[@]}")" \
@ -129,7 +142,7 @@ if [ "${GENS}" = "all" ] || grep -qw "informer" <<<"${GENS}"; then
"$@"
fi
if [ "${GENS}" = "all" ] || grep -qw "openapi" <<<"${GENS}"; then
if grep -qw "openapi" <<<"${GENS}"; then
echo "Generating OpenAPI definitions for ${GROUPS_WITH_VERSIONS} at ${OUTPUT_PKG}/openapi"
declare -a OPENAPI_EXTRA_PACKAGES
"${gobin}/openapi-gen" \