From 5a72bb001f5cd93e0f38beafaa1201028beb9595 Mon Sep 17 00:00:00 2001 From: Mike Danese Date: Thu, 10 Sep 2020 21:21:12 -0700 Subject: [PATCH] hack/lib/util.sh: some bash cleanups * switched one spot to use kube::logging * make kube::util::find-binary return an error when it doesn't find anything so that hack scripts fail fast instead of with '' binary not found errors. * this required deleting some genfeddoc stuff. the binary no longer exists in k/k repo since we removed federation/, and I don't see it in https://github.com/kubernetes-sigs/kubefed/ either. I'm assuming that it's gone for good now. --- hack/lib/util.sh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/hack/lib/util.sh b/hack/lib/util.sh index 5c90902d710..dc70ea1f157 100755 --- a/hack/lib/util.sh +++ b/hack/lib/util.sh @@ -223,6 +223,12 @@ kube::util::find-binary-for-platform() { # List most recently-updated location. local -r bin=$( (ls -t "${locations[@]}" 2>/dev/null || true) | head -1 ) + + if [[ -z "${bin}" ]]; then + kube::log::error "Failed to find binary ${lookfor} for platform ${platform}" + return 1 + fi + echo -n "${bin}" } @@ -242,11 +248,6 @@ kube::util::gen-docs() { genkubedocs=$(kube::util::find-binary "genkubedocs") genman=$(kube::util::find-binary "genman") genyaml=$(kube::util::find-binary "genyaml") - genfeddocs=$(kube::util::find-binary "genfeddocs") - - # TODO: If ${genfeddocs} is not used from anywhere (it isn't used at - # least from k/k tree), remove it completely. - kube::util::sourced_variable "${genfeddocs}" mkdir -p "${dest}/docs/user-guide/kubectl/" "${gendocs}" "${dest}/docs/user-guide/kubectl/" @@ -764,7 +765,7 @@ function kube::util::check-file-in-alphabetical-order { # Checks whether jq is installed. function kube::util::require-jq { if ! command -v jq &>/dev/null; then - echo "jq not found. Please install." 1>&2 + kube::log::error "jq not found. Please install." return 1 fi }