mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
Fixes get-password for gce
This commit is contained in:
parent
acbadc8ade
commit
06aa8bd164
@ -189,13 +189,26 @@ function detect-master () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Ensure that we have a password created for validating to the master. Will
|
# 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:
|
# Vars set:
|
||||||
# KUBE_USER
|
# KUBE_USER
|
||||||
# KUBE_PASSWORD
|
# KUBE_PASSWORD
|
||||||
function get-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
|
if [[ -r "$file" ]]; then
|
||||||
KUBE_USER=$(cat "$file" | python -c 'import json,sys;print json.load(sys.stdin)["User"]')
|
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"]')
|
KUBE_PASSWORD=$(cat "$file" | python -c 'import json,sys;print json.load(sys.stdin)["Password"]')
|
||||||
|
Loading…
Reference in New Issue
Block a user