diff --git a/hack/lib/protoc.sh b/hack/lib/protoc.sh index 0812f76eaee..21806edf880 100644 --- a/hack/lib/protoc.sh +++ b/hack/lib/protoc.sh @@ -101,19 +101,20 @@ function kube::protoc::diff() { } function kube::protoc::install() { + local os + local arch + local download_folder + local download_file + local third_party_dir + + os=$(kube::util::host_os) + arch=$(kube::util::host_arch) + download_folder="protoc-v${PROTOC_VERSION}-${os}-${arch}" + download_file="${download_folder}.zip" + third_party_dir="${KUBE_ROOT}/third_party" # run in a subshell to isolate caller from directory changes ( - local os - local arch - local download_folder - local download_file - - os=$(kube::util::host_os) - arch=$(kube::util::host_arch) - download_folder="protoc-v${PROTOC_VERSION}-${os}-${arch}" - download_file="${download_folder}.zip" - - cd "${KUBE_ROOT}/third_party" || return 1 + cd "${third_party_dir}" || return 1 if [[ $(readlink protoc) != "${download_folder}" ]]; then local url if [[ ${os} == "darwin" ]]; then @@ -136,8 +137,12 @@ function kube::protoc::install() { rm "${download_file}" fi kube::log::info "protoc v${PROTOC_VERSION} installed. To use:" - kube::log::info "export PATH=\"$(pwd)/protoc:\${PATH}\"" + kube::log::info "export PATH=\"${third_party_dir}/protoc:\${PATH}\"" ) + # export updated PATH so install-protoc.sh can be sourced + # CLI callers will need to use the export indicated above + PATH="${third_party_dir}/protoc:${PATH}" + export PATH } # Marker function to indicate protoc.sh has been fully sourced diff --git a/hack/update-codegen.sh b/hack/update-codegen.sh index 4eefcb7a34e..6e2172182a0 100755 --- a/hack/update-codegen.sh +++ b/hack/update-codegen.sh @@ -52,6 +52,8 @@ fi echo "installing goimports from hack/tools" go -C "${KUBE_ROOT}/hack/tools" install golang.org/x/tools/cmd/goimports +kube::protoc::install + # Generate a list of directories we don't want to play in. DIRS_TO_AVOID=() kube::util::read-array DIRS_TO_AVOID < <(