Fix bug in code generator which prevented it from generating code

Signed-off-by: Andrew Keesler <akeesler@vmware.com>
This commit is contained in:
Ryan Richard 2020-08-21 12:30:50 -07:00 committed by Andrew Keesler
parent 2b297c28d5
commit 0a805861ea
2 changed files with 9 additions and 2 deletions

View File

@ -12,6 +12,10 @@ CODEGEN_IMAGE=${CODEGEN_IMAGE:-"gcr.io/tanzu-user-authentication/k8s-code-genera
BASE_PKG="github.com/suzerain-io/pinniped" BASE_PKG="github.com/suzerain-io/pinniped"
# This script assumes that your current working directory is the top of the module
# in which you would like to generate code.
MOD_DIR=$(pwd)
function codegen::ensure_module_in_gopath() { function codegen::ensure_module_in_gopath() {
# This should be something like "kubernetes/1.19/api". # This should be something like "kubernetes/1.19/api".
local pkg_name="$(realpath "--relative-to=$ROOT" "$MOD_DIR")" local pkg_name="$(realpath "--relative-to=$ROOT" "$MOD_DIR")"
@ -49,6 +53,7 @@ function codegen::generate_for_module() {
case "${mod_basename_for_version}" in case "${mod_basename_for_version}" in
1.19/api) 1.19/api)
echo "GENERATING CODE for $mod_basename_for_version"
codegen::invoke_code_generator generate-groups "${mod_basename_for_version}" \ codegen::invoke_code_generator generate-groups "${mod_basename_for_version}" \
deepcopy,defaulter \ deepcopy,defaulter \
"${BASE_PKG}/kubernetes/1.19/api/generated" \ "${BASE_PKG}/kubernetes/1.19/api/generated" \
@ -62,12 +67,15 @@ function codegen::generate_for_module() {
"pinniped:v1alpha1 crdpinniped:v1alpha1" "pinniped:v1alpha1 crdpinniped:v1alpha1"
;; ;;
1.19/client-go) 1.19/client-go)
echo "GENERATING CODE for $mod_basename_for_version"
codegen::invoke_code_generator generate-groups "${mod_basename_for_version}" \ codegen::invoke_code_generator generate-groups "${mod_basename_for_version}" \
client,lister,informer \ client,lister,informer \
"${BASE_PKG}/kubernetes/1.19/client-go" \ "${BASE_PKG}/kubernetes/1.19/client-go" \
"${BASE_PKG}/kubernetes/1.19/api/apis" \ "${BASE_PKG}/kubernetes/1.19/api/apis" \
"pinniped:v1alpha1 crdpinniped:v1alpha1" "pinniped:v1alpha1 crdpinniped:v1alpha1"
;; ;;
*)
echo "Skipping $mod_basename_for_version because it does not contain any code to generate"
esac esac
} }

View File

@ -59,10 +59,9 @@ function with_modules() {
for mod_file in $(find . -maxdepth 4 -name go.mod | sort); do for mod_file in $(find . -maxdepth 4 -name go.mod | sort); do
mod_dir="$(dirname "${mod_file}")" mod_dir="$(dirname "${mod_file}")"
( (
export MOD_DIR
echo "=> " echo "=> "
echo " cd ${mod_dir} && ${cmd}" echo " cd ${mod_dir} && ${cmd}"
cd "${mod_dir}" && MOD_DIR="$(pwd)" && ${cmd} cd "${mod_dir}" && ${cmd}
) )
done done
popd popd