Fix path munging funcs and usage
Our `realpath` and `readlink -f` functions (required only because of MacOS, thanks Steve) were poor substitutes at best. Mostly they were downright broken. This thoroughly overhauls them and adds a test (in comments, since we don't seem to have shell tests). For all the interesting cases I could think of, the fakes act just like the real thing. Then use those and canonicalize KUBE_ROOT. In order to make recursive calls of our shell tool not additively grow `pwd` we have to essentially make the sourcing of init.sh idempotent.
This commit is contained in:
@@ -309,7 +309,7 @@ kube::golang::setup_env() {
|
||||
# resultant binaries. Go will not let us use GOBIN with `go install` and
|
||||
# cross-compiling, and `go install -o <file>` only works for a single pkg.
|
||||
local subdir
|
||||
subdir=$(pwd | sed "s|$KUBE_ROOT||")
|
||||
subdir=$(kube::realpath . | sed "s|$KUBE_ROOT||")
|
||||
cd "${KUBE_GOPATH}/src/${KUBE_GO_PACKAGE}/${subdir}"
|
||||
|
||||
# Unset GOBIN in case it already exists in the current session.
|
||||
|
Reference in New Issue
Block a user