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:
Tim Hockin
2016-04-23 21:45:03 -07:00
parent 817abc3213
commit 9a83015e60
4 changed files with 82 additions and 28 deletions

View File

@@ -18,12 +18,6 @@ kube::util::sortable_date() {
date "+%Y%m%d-%H%M%S"
}
# this mimics the behavior of linux realpath which is not shipped by default with
# mac OS X
kube::util::realpath() {
[[ $1 = /* ]] && echo "$1" | sed 's/\/$//' || echo "$PWD/${1#./}" | sed 's/\/$//'
}
kube::util::wait_for_url() {
local url=$1
local prefix=${2:-}