From 549504dffff3e04fa81cdcb442b1549611fe84f9 Mon Sep 17 00:00:00 2001 From: Eric Tune Date: Wed, 11 Feb 2015 14:24:36 -0800 Subject: [PATCH] Don't fail get-password when no current-context. --- cluster/gce/util.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cluster/gce/util.sh b/cluster/gce/util.sh index 5345ba91ce4..a567b016cd5 100755 --- a/cluster/gce/util.sh +++ b/cluster/gce/util.sh @@ -199,9 +199,9 @@ function detect-master () { # KUBE_PASSWORD function get-password { # go template to extract the auth-path of the current-context user - local template='{{$ctx := index . "current-context"}}{{$user := index . "contexts" $ctx "user"}}{{index . "users" $user "auth-path"}}' + local template='{{with $ctx := index . "current-context"}}{{$user := index . "contexts" $ctx "user"}}{{index . "users" $user "auth-path"}}{{end}' local file=$("${KUBE_ROOT}/cluster/kubectl.sh" config view -o template --template="${template}") - if [[ -r "$file" ]]; then + if [[ ! -z "$file" && -r "$file" ]]; then KUBE_USER=$(cat "$file" | python -c 'import json,sys;print json.load(sys.stdin)["User"]') KUBE_PASSWORD=$(cat "$file" | python -c 'import json,sys;print json.load(sys.stdin)["Password"]') return