From 71174aa2da1eebbd6991cc44532b78102d6c0216 Mon Sep 17 00:00:00 2001 From: Jordan Liggitt Date: Mon, 23 Jan 2023 09:15:27 -0500 Subject: [PATCH] Generate proto uncontainerized if host has required protoc version --- hack/update-codegen.sh | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/hack/update-codegen.sh b/hack/update-codegen.sh index 18e1b09e481..ae451465b1b 100755 --- a/hack/update-codegen.sh +++ b/hack/update-codegen.sh @@ -24,6 +24,7 @@ KUBE_VERBOSE="${KUBE_VERBOSE:-1}" KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. source "${KUBE_ROOT}/hack/lib/init.sh" +source "${KUBE_ROOT}/hack/lib/protoc.sh" cd "${KUBE_ROOT}" kube::golang::setup_env @@ -115,7 +116,12 @@ function codegen::protobuf() { ':(glob)**/generated.pb.go' \ | xargs -0 rm -f - build/run.sh hack/update-generated-protobuf-dockerized.sh "${apis[@]}" + if kube::protoc::check_protoc >/dev/null; then + hack/update-generated-protobuf-dockerized.sh "${apis[@]}" + else + kube::log::status "protoc ${PROTOC_VERSION} not found (can install with hack/install-protoc.sh); generating containerized..." + build/run.sh hack/update-generated-protobuf-dockerized.sh "${apis[@]}" + fi } # Generates types_swagger_doc_generated file for the given group version. @@ -918,10 +924,15 @@ function codegen::protobindings() { | xargs -0 rm -f done - # NOTE: All output from this script needs to be copied back to the calling - # source tree. This is managed in kube::build::copy_output in build/common.sh. - # If the output set is changed update that function. - build/run.sh hack/update-generated-proto-bindings-dockerized.sh "${apis[@]}" + if kube::protoc::check_protoc >/dev/null; then + hack/update-generated-proto-bindings-dockerized.sh "${apis[@]}" + else + kube::log::status "protoc ${PROTOC_VERSION} not found (can install with hack/install-protoc.sh); generating containerized..." + # NOTE: All output from this script needs to be copied back to the calling + # source tree. This is managed in kube::build::copy_output in build/common.sh. + # If the output set is changed update that function. + build/run.sh hack/update-generated-proto-bindings-dockerized.sh "${apis[@]}" + fi } #