From 0a805861ea60acd0b4349d3ef48794e81f1f6561 Mon Sep 17 00:00:00 2001 From: Ryan Richard Date: Fri, 21 Aug 2020 12:30:50 -0700 Subject: [PATCH] Fix bug in code generator which prevented it from generating code Signed-off-by: Andrew Keesler --- hack/lib/codegen.sh | 8 ++++++++ hack/module.sh | 3 +-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/hack/lib/codegen.sh b/hack/lib/codegen.sh index 9f79e7af..982cda8d 100755 --- a/hack/lib/codegen.sh +++ b/hack/lib/codegen.sh @@ -12,6 +12,10 @@ CODEGEN_IMAGE=${CODEGEN_IMAGE:-"gcr.io/tanzu-user-authentication/k8s-code-genera 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() { # This should be something like "kubernetes/1.19/api". local pkg_name="$(realpath "--relative-to=$ROOT" "$MOD_DIR")" @@ -49,6 +53,7 @@ function codegen::generate_for_module() { case "${mod_basename_for_version}" in 1.19/api) + echo "GENERATING CODE for $mod_basename_for_version" codegen::invoke_code_generator generate-groups "${mod_basename_for_version}" \ deepcopy,defaulter \ "${BASE_PKG}/kubernetes/1.19/api/generated" \ @@ -62,12 +67,15 @@ function codegen::generate_for_module() { "pinniped:v1alpha1 crdpinniped:v1alpha1" ;; 1.19/client-go) + echo "GENERATING CODE for $mod_basename_for_version" codegen::invoke_code_generator generate-groups "${mod_basename_for_version}" \ client,lister,informer \ "${BASE_PKG}/kubernetes/1.19/client-go" \ "${BASE_PKG}/kubernetes/1.19/api/apis" \ "pinniped:v1alpha1 crdpinniped:v1alpha1" ;; + *) + echo "Skipping $mod_basename_for_version because it does not contain any code to generate" esac } diff --git a/hack/module.sh b/hack/module.sh index be1e7e12..f51eef06 100755 --- a/hack/module.sh +++ b/hack/module.sh @@ -59,10 +59,9 @@ function with_modules() { for mod_file in $(find . -maxdepth 4 -name go.mod | sort); do mod_dir="$(dirname "${mod_file}")" ( - export MOD_DIR echo "=> " echo " cd ${mod_dir} && ${cmd}" - cd "${mod_dir}" && MOD_DIR="$(pwd)" && ${cmd} + cd "${mod_dir}" && ${cmd} ) done popd