mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-10 04:27:54 +00:00
Merge pull request #122470 from thockin/fix_openapi_chdir
Fix update-openapi-spec to not change caller CWD
This commit is contained in:
commit
f55d18a1cf
@ -144,42 +144,49 @@ kube::etcd::cleanup() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
kube::etcd::install() {
|
kube::etcd::install() {
|
||||||
local os
|
# Make sure that we will abort if the inner shell fails.
|
||||||
local arch
|
set -o errexit
|
||||||
|
set -o pipefail
|
||||||
|
set -o nounset
|
||||||
|
|
||||||
os=$(kube::util::host_os)
|
# We change directories below, so this subshell is needed.
|
||||||
arch=$(kube::util::host_arch)
|
(
|
||||||
|
local os
|
||||||
|
local arch
|
||||||
|
|
||||||
cd "${KUBE_ROOT}/third_party" || return 1
|
os=$(kube::util::host_os)
|
||||||
if [[ $(readlink etcd) == etcd-v${ETCD_VERSION}-${os}-* ]]; then
|
arch=$(kube::util::host_arch)
|
||||||
kube::log::info "etcd v${ETCD_VERSION} already installed. To use:"
|
|
||||||
kube::log::info "export PATH=\"$(pwd)/etcd:\${PATH}\""
|
|
||||||
# export into current process
|
|
||||||
PATH="$(pwd)/etcd:${PATH}"
|
|
||||||
export PATH
|
|
||||||
return #already installed
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ ${os} == "darwin" ]]; then
|
cd "${KUBE_ROOT}/third_party" || return 1
|
||||||
download_file="etcd-v${ETCD_VERSION}-${os}-${arch}.zip"
|
if [[ $(readlink etcd) == etcd-v${ETCD_VERSION}-${os}-* ]]; then
|
||||||
url="https://github.com/etcd-io/etcd/releases/download/v${ETCD_VERSION}/${download_file}"
|
V=3 kube::log::info "etcd v${ETCD_VERSION} is already installed"
|
||||||
kube::util::download_file "${url}" "${download_file}"
|
return 0 # already installed
|
||||||
unzip -o "${download_file}"
|
fi
|
||||||
ln -fns "etcd-v${ETCD_VERSION}-${os}-${arch}" etcd
|
|
||||||
rm "${download_file}"
|
if [[ ${os} == "darwin" ]]; then
|
||||||
elif [[ ${os} == "linux" ]]; then
|
download_file="etcd-v${ETCD_VERSION}-${os}-${arch}.zip"
|
||||||
url="https://github.com/etcd-io/etcd/releases/download/v${ETCD_VERSION}/etcd-v${ETCD_VERSION}-${os}-${arch}.tar.gz"
|
url="https://github.com/etcd-io/etcd/releases/download/v${ETCD_VERSION}/${download_file}"
|
||||||
download_file="etcd-v${ETCD_VERSION}-${os}-${arch}.tar.gz"
|
kube::util::download_file "${url}" "${download_file}"
|
||||||
kube::util::download_file "${url}" "${download_file}"
|
unzip -o "${download_file}"
|
||||||
tar xzf "${download_file}"
|
ln -fns "etcd-v${ETCD_VERSION}-${os}-${arch}" etcd
|
||||||
ln -fns "etcd-v${ETCD_VERSION}-${os}-${arch}" etcd
|
rm "${download_file}"
|
||||||
rm "${download_file}"
|
elif [[ ${os} == "linux" ]]; then
|
||||||
else
|
url="https://github.com/etcd-io/etcd/releases/download/v${ETCD_VERSION}/etcd-v${ETCD_VERSION}-${os}-${arch}.tar.gz"
|
||||||
kube::log::info "${os} is NOT supported."
|
download_file="etcd-v${ETCD_VERSION}-${os}-${arch}.tar.gz"
|
||||||
fi
|
kube::util::download_file "${url}" "${download_file}"
|
||||||
kube::log::info "etcd v${ETCD_VERSION} installed. To use:"
|
tar xzf "${download_file}"
|
||||||
kube::log::info "export PATH=\"$(pwd)/etcd:\${PATH}\""
|
ln -fns "etcd-v${ETCD_VERSION}-${os}-${arch}" etcd
|
||||||
# export into current process
|
rm "${download_file}"
|
||||||
PATH="$(pwd)/etcd:${PATH}"
|
else
|
||||||
|
kube::log::info "${os} is NOT supported."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
V=4 kube::log::info "installed etcd v${ETCD_VERSION}"
|
||||||
|
return 0 # newly installed
|
||||||
|
)
|
||||||
|
# Through the magic of errexit, we will not get here if the above shell
|
||||||
|
# fails!
|
||||||
|
PATH="${KUBE_ROOT}/third_party/etcd:${PATH}" # export into current process
|
||||||
export PATH
|
export PATH
|
||||||
|
V=3 kube::log::info "added etcd to PATH: ${KUBE_ROOT}/third_party/etcd"
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user