mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 15:05:27 +00:00
Use cd
and pwd
in a subshell to define ${KUBE_REPO_ROOT}
The old method (using `readlink`) was convoluted and not portable. We can achieve the same result using only bash builtins. Signed-off-by: Filipe Brandenburger <filbranden@google.com>
This commit is contained in:
parent
09dd081543
commit
391cd856c1
@ -103,16 +103,15 @@ kube::setup_go_environment() {
|
||||
# KUBE_TARGET - Path where output Go files are saved.
|
||||
# KUBE_GO_PACKAGE - Full name of the Kubernetes Go package.
|
||||
|
||||
KUBE_REPO_ROOT=$(dirname "${BASH_SOURCE:-$0}")/..
|
||||
if [[ "${OSTYPE:-}" == *darwin* ]]; then
|
||||
# Make the path absolute if it is not.
|
||||
if [[ "${KUBE_REPO_ROOT}" != /* ]]; then
|
||||
KUBE_REPO_ROOT=${PWD}/${KUBE_REPO_ROOT}
|
||||
fi
|
||||
else
|
||||
# Resolve symlinks.
|
||||
KUBE_REPO_ROOT=$(readlink -f "${KUBE_REPO_ROOT}")
|
||||
fi
|
||||
# Make ${KUBE_REPO_ROOT} an absolute path.
|
||||
KUBE_REPO_ROOT=$(
|
||||
set -eu
|
||||
unset CDPATH
|
||||
scripts_dir=$(dirname "${BASH_SOURCE[0]}")
|
||||
cd "${scripts_dir}"
|
||||
cd ..
|
||||
pwd
|
||||
)
|
||||
export KUBE_REPO_ROOT
|
||||
|
||||
KUBE_TARGET="${KUBE_REPO_ROOT}/output/go"
|
||||
|
Loading…
Reference in New Issue
Block a user