mirror of https://github.com/k3s-io/k3s
Install ensured godep inside hermetic GOPATH
parent
9d241ec454
commit
c0c62821d7
|
@ -441,28 +441,35 @@ kube::util::ensure_clean_working_dir() {
|
|||
|
||||
# Ensure that the given godep version is installed and in the path. Almost
|
||||
# nobody should use any version but the default.
|
||||
#
|
||||
# Sets:
|
||||
# KUBE_GODEP: The path to the godep binary
|
||||
#
|
||||
kube::util::ensure_godep_version() {
|
||||
GODEP_VERSION=${1:-"v80"} # this version is known to work
|
||||
local godep_target_version=${1:-"v80-k8s-r1"} # this version is known to work
|
||||
|
||||
if [[ "$(godep version 2>/dev/null)" == *"godep ${GODEP_VERSION}"* ]]; then
|
||||
# If KUBE_GODEP is already set, and it's the right version, then use it.
|
||||
if [[ -n "${KUBE_GODEP:-}" && "$(${KUBE_GODEP:?} version 2>/dev/null)" == *"godep ${godep_target_version}"* ]]; then
|
||||
kube::log::status "Using ${KUBE_GODEP}"
|
||||
return
|
||||
fi
|
||||
|
||||
kube::log::status "Installing godep version ${GODEP_VERSION}"
|
||||
go install k8s.io/kubernetes/vendor/github.com/tools/godep/
|
||||
if ! which godep >/dev/null 2>&1; then
|
||||
kube::log::error "Can't find godep - is your GOPATH 'bin' in your PATH?"
|
||||
kube::log::error " GOPATH: ${GOPATH}"
|
||||
kube::log::error " PATH: ${PATH}"
|
||||
return 1
|
||||
# If GODEP is in the path, then use it.
|
||||
if [[ "$(godep version 2>/dev/null)" == *"godep ${godep_target_version}"* ]]; then
|
||||
export KUBE_GODEP="$(which godep)"
|
||||
kube::log::status "Using ${KUBE_GODEP}"
|
||||
return
|
||||
fi
|
||||
|
||||
if [[ "$(godep version 2>/dev/null)" != *"godep ${GODEP_VERSION}"* ]]; then
|
||||
kube::log::error "Wrong godep version - is your GOPATH 'bin' in your PATH?"
|
||||
kube::log::error " expected: godep ${GODEP_VERSION}"
|
||||
kube::log::error " got: $(godep version)"
|
||||
kube::log::error " GOPATH: ${GOPATH}"
|
||||
kube::log::error " PATH: ${PATH}"
|
||||
kube::log::status "Installing godep version ${godep_target_version}"
|
||||
# Run in hermetic GOPATH
|
||||
kube::golang::setup_env
|
||||
go install k8s.io/kubernetes/third_party/forked/godep
|
||||
export KUBE_GODEP="${KUBE_GOPATH}/bin/godep"
|
||||
kube::log::status "Installed ${KUBE_GODEP}"
|
||||
|
||||
if [[ "$(${KUBE_GODEP:?} version 2>/dev/null)" != *"godep ${godep_target_version}"* ]]; then
|
||||
kube::log::error "Expected godep ${godep_target_version} from ${KUBE_GODEP}, got $(${KUBE_GODEP:?} version)"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue