Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use kubectl config -o template to get password in gce kube-up #4205

Merged
merged 1 commit into from
Feb 6, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 3 additions & 11 deletions cluster/gce/util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -198,17 +198,9 @@ function detect-master () {
# KUBE_USER
# KUBE_PASSWORD
function get-password {
local get_auth_path='''
import yaml, sys
cfg = yaml.load(sys.stdin)
try:
current = cfg["current-context"]
user = cfg["contexts"][current]["user"]
print cfg["users"][user]["auth-path"]
except KeyError:
pass
'''
local file=$("${KUBE_ROOT}/cluster/kubectl.sh" config view --global | python -c "${get_auth_path}")
# 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 file=$("${KUBE_ROOT}/cluster/kubectl.sh" config view -o template --template="${template}")
if [[ -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"]')
Expand Down