diff --git a/hack/lib/init.sh b/hack/lib/init.sh index 17f69c91c53..90086ad830a 100755 --- a/hack/lib/init.sh +++ b/hack/lib/init.sh @@ -18,6 +18,9 @@ set -o errexit set -o nounset set -o pipefail +# Short-circuit if init.sh has already been sourced +[[ $(type -t kube::init::loaded) == function ]] && return 0 + # Unset CDPATH so that path interpolation can work correctly # https://github.com/kubernetes/kubernetes/issues/52255 unset CDPATH @@ -211,3 +214,8 @@ kube::realpath() { fi kube::readlinkdashf "${1}" } + +# Marker function to indicate init.sh has been fully sourced +kube::init::loaded() { + return 0 +} diff --git a/hack/lib/protoc.sh b/hack/lib/protoc.sh index 4c8a3920146..6b080084a92 100644 --- a/hack/lib/protoc.sh +++ b/hack/lib/protoc.sh @@ -18,6 +18,9 @@ set -o errexit set -o nounset set -o pipefail +# Short-circuit if protoc.sh has already been sourced +[[ $(type -t kube::protoc::loaded) == function ]] && return 0 + # The root of the build/dist directory KUBE_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd -P)" source "${KUBE_ROOT}/hack/lib/init.sh" @@ -134,3 +137,8 @@ function kube::protoc::install() { kube::log::info "export PATH=\"$(pwd)/protoc:\${PATH}\"" ) } + +# Marker function to indicate protoc.sh has been fully sourced +kube::protoc::loaded() { + return 0 +}