Skip to content

Commit

Permalink
Don't fail get-password when no current-context.
Browse files Browse the repository at this point in the history
  • Loading branch information
erictune committed Feb 11, 2015
1 parent 20f7cbb commit 549504d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cluster/gce/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 549504d

Please sign in to comment.