Skip to content

Commit babe378

Browse files
author
OpenShift Bot
authored
Merge pull request openshift#15154 from stevekuznetsov/skuznets/install-go-dependencies
Merged by openshift-bot
2 parents 849edbb + c73ba1c commit babe378

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

hack/lib/util/ensure.sh

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,19 +67,29 @@ Provide the binary and try running $0 again."
6767
readonly -f os::util::ensure::built_binary_exists
6868

6969
# os::util::ensure::gopath_binary_exists ensures that the
70-
# given binary exists on the system in $GOPATH.
70+
# given binary exists on the system in $GOPATH. If it
71+
# doesn't, we will attempt to build it if we can determine
72+
# the correct install path for the binary.
7173
#
7274
# Globals:
7375
# - GOPATH
7476
# Arguments:
7577
# - 1: binary to search for
78+
# - 2: [optional] path to install from
7679
# Returns:
7780
# None
7881
function os::util::ensure::gopath_binary_exists() {
7982
local binary="$1"
83+
local install_path="${2:-}"
8084

8185
if ! os::util::find::gopath_binary "${binary}" >/dev/null 2>&1; then
82-
os::log::fatal "Required \`${binary}\` binary was not found in \$GOPATH."
86+
if [[ -n "${install_path:-}" ]]; then
87+
os::log::info "No installed \`${binary}\` was found in \$GOPATH. Attempting to install using:
88+
$ go get ${install_path}"
89+
go get "${install_path}"
90+
else
91+
os::log::fatal "Required \`${binary}\` binary was not found in \$GOPATH."
92+
fi
8393
fi
8494
}
8595
readonly -f os::util::ensure::gopath_binary_exists

0 commit comments

Comments
 (0)