Skip to content

Commit

Permalink
Add utility function to install go package at a particular commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ixdy committed Jul 18, 2017
1 parent ebf24c1 commit 9ac0950
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions hack/lib/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,23 @@ kube::util::ensure_godep_version() {
godep version
}

# Installs the specified go package at a particular commit.
kube::util::go_install_from_commit() {
local -r pkg=$1
local -r commit=$2

kube::util::ensure-temp-dir
mkdir -p "${KUBE_TEMP}/go/src"
GOPATH="${KUBE_TEMP}/go" go get -d -u "${pkg}" 2>/dev/null
(
cd "${KUBE_TEMP}/go/src/${pkg}"
git checkout -q "${commit}"
GOPATH="${KUBE_TEMP}/go" go install "${pkg}"
)
PATH="${KUBE_TEMP}/go/bin:${PATH}"
hash -r # force bash to clear PATH cache
}

# Checks that the GOPATH is simple, i.e. consists only of one directory, not multiple.
kube::util::ensure_single_dir_gopath() {
if [[ "${GOPATH}" == *:* ]]; then
Expand Down

0 comments on commit 9ac0950

Please sign in to comment.