Merge pull request #4097 from jlowdermilk/fix-jenkins-e2e

Fix get-password for gce
This commit is contained in:
Zach Loafman 2015-02-03 20:09:48 -08:00
commit ffe6149d51

View File

@ -189,13 +189,26 @@ function detect-master () {
}
# Ensure that we have a password created for validating to the master. Will
# read from $HOME/.kubernetres_auth if available.
# read from the kubernetes auth-file for the current context if available.
#
# Assumed vars
# KUBE_ROOT
#
# Vars set:
# KUBE_USER
# KUBE_PASSWORD
function get-password {
local file="$HOME/.kubernetes_auth"
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}")
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"]')