add P9K_KUBECONTEXT_USER

pull/445/head
romkatv 5 years ago
parent 9c21f4b273
commit 5e42c4c930

@ -865,6 +865,8 @@
# - P9K_KUBECONTEXT_NAMESPACE The current context's namespace. Corresponds to column NAMESPACE # - P9K_KUBECONTEXT_NAMESPACE The current context's namespace. Corresponds to column NAMESPACE
# in the output of `kubectl config get-contexts`. If there is no # in the output of `kubectl config get-contexts`. If there is no
# namespace, the parameter is set to "default". # namespace, the parameter is set to "default".
# - P9K_KUBECONTEXT_USER The current context's user. Corresponds to column AUTHINFO in the
# output of `kubectl config get-contexts`.
# #
# If the context points to Google Kubernetes Engine (GKE) or Elastic Kubernetes Service (EKS), # If the context points to Google Kubernetes Engine (GKE) or Elastic Kubernetes Service (EKS),
# the following extra parameters are available: # the following extra parameters are available:

@ -838,6 +838,8 @@
# - P9K_KUBECONTEXT_NAMESPACE The current context's namespace. Corresponds to column NAMESPACE # - P9K_KUBECONTEXT_NAMESPACE The current context's namespace. Corresponds to column NAMESPACE
# in the output of `kubectl config get-contexts`. If there is no # in the output of `kubectl config get-contexts`. If there is no
# namespace, the parameter is set to "default". # namespace, the parameter is set to "default".
# - P9K_KUBECONTEXT_USER The current context's user. Corresponds to column AUTHINFO in the
# output of `kubectl config get-contexts`.
# #
# If the context points to Google Kubernetes Engine (GKE) or Elastic Kubernetes Service (EKS), # If the context points to Google Kubernetes Engine (GKE) or Elastic Kubernetes Service (EKS),
# the following extra parameters are available: # the following extra parameters are available:

@ -838,6 +838,8 @@
# - P9K_KUBECONTEXT_NAMESPACE The current context's namespace. Corresponds to column NAMESPACE # - P9K_KUBECONTEXT_NAMESPACE The current context's namespace. Corresponds to column NAMESPACE
# in the output of `kubectl config get-contexts`. If there is no # in the output of `kubectl config get-contexts`. If there is no
# namespace, the parameter is set to "default". # namespace, the parameter is set to "default".
# - P9K_KUBECONTEXT_USER The current context's user. Corresponds to column AUTHINFO in the
# output of `kubectl config get-contexts`.
# #
# If the context points to Google Kubernetes Engine (GKE) or Elastic Kubernetes Service (EKS), # If the context points to Google Kubernetes Engine (GKE) or Elastic Kubernetes Service (EKS),
# the following extra parameters are available: # the following extra parameters are available:

@ -897,6 +897,8 @@
# - P9K_KUBECONTEXT_NAMESPACE The current context's namespace. Corresponds to column NAMESPACE # - P9K_KUBECONTEXT_NAMESPACE The current context's namespace. Corresponds to column NAMESPACE
# in the output of `kubectl config get-contexts`. If there is no # in the output of `kubectl config get-contexts`. If there is no
# namespace, the parameter is set to "default". # namespace, the parameter is set to "default".
# - P9K_KUBECONTEXT_USER The current context's user. Corresponds to column AUTHINFO in the
# output of `kubectl config get-contexts`.
# #
# If the context points to Google Kubernetes Engine (GKE) or Elastic Kubernetes Service (EKS), # If the context points to Google Kubernetes Engine (GKE) or Elastic Kubernetes Service (EKS),
# the following extra parameters are available: # the following extra parameters are available:

@ -3836,7 +3836,8 @@ prompt_kubecontext() {
(( $+commands[kubectl] )) || return (( $+commands[kubectl] )) || return
if ! _p9k_cache_stat_get $0 ${(s.:.)${KUBECONFIG:-$HOME/.kube/config}}; then if ! _p9k_cache_stat_get $0 ${(s.:.)${KUBECONFIG:-$HOME/.kube/config}}; then
local name namespace cluster cloud_name cloud_account cloud_zone cloud_cluster text state local name namespace cluster user cloud_name cloud_account cloud_zone cloud_cluster text state
local -a match
() { () {
local cfg && cfg=(${(f)"$(kubectl config view -o=yaml 2>/dev/null)"}) || return local cfg && cfg=(${(f)"$(kubectl config view -o=yaml 2>/dev/null)"}) || return
local ctx=(${(@M)cfg:#current-context: [^\"\'\|\>]*}) local ctx=(${(@M)cfg:#current-context: [^\"\'\|\>]*})
@ -3856,6 +3857,8 @@ prompt_kubecontext() {
cluster=$match[1] cluster=$match[1]
elif [[ $line == (#b)' namespace: '([^\"\'\|\>]*) ]]; then elif [[ $line == (#b)' namespace: '([^\"\'\|\>]*) ]]; then
namespace=$match[1] namespace=$match[1]
elif [[ $line == (#b)' user: '([^\"\'\|\>]*) ]]; then
user=$match[1]
fi fi
done done
} }
@ -3895,18 +3898,19 @@ prompt_kubecontext() {
fi fi
done done
fi fi
_p9k_cache_stat_set "$name" "$namespace" "$cluster" "$cloud_name" "$cloud_account" "$cloud_zone" "$cloud_cluster" "$text" "$state" _p9k_cache_stat_set "$name" "$namespace" "$cluster" "$user" "$cloud_name" "$cloud_account" "$cloud_zone" "$cloud_cluster" "$text" "$state"
fi fi
typeset -g P9K_KUBECONTEXT_NAME=$_p9k_cache_val[1] typeset -g P9K_KUBECONTEXT_NAME=$_p9k_cache_val[1]
typeset -g P9K_KUBECONTEXT_NAMESPACE=$_p9k_cache_val[2] typeset -g P9K_KUBECONTEXT_NAMESPACE=$_p9k_cache_val[2]
typeset -g P9K_KUBECONTEXT_CLUSTER=$_p9k_cache_val[3] typeset -g P9K_KUBECONTEXT_CLUSTER=$_p9k_cache_val[3]
typeset -g P9K_KUBECONTEXT_CLOUD_NAME=$_p9k_cache_val[4] typeset -g P9K_KUBECONTEXT_USER=$_p9k_cache_val[4]
typeset -g P9K_KUBECONTEXT_CLOUD_ACCOUNT=$_p9k_cache_val[5] typeset -g P9K_KUBECONTEXT_CLOUD_NAME=$_p9k_cache_val[5]
typeset -g P9K_KUBECONTEXT_CLOUD_ZONE=$_p9k_cache_val[6] typeset -g P9K_KUBECONTEXT_CLOUD_ACCOUNT=$_p9k_cache_val[6]
typeset -g P9K_KUBECONTEXT_CLOUD_CLUSTER=$_p9k_cache_val[7] typeset -g P9K_KUBECONTEXT_CLOUD_ZONE=$_p9k_cache_val[7]
[[ -n $_p9k_cache_val[8] ]] || return typeset -g P9K_KUBECONTEXT_CLOUD_CLUSTER=$_p9k_cache_val[8]
_p9k_prompt_segment $0$_p9k_cache_val[9] magenta white KUBERNETES_ICON 0 '' "${_p9k_cache_val[8]//\%/%%}" [[ -n $_p9k_cache_val[9] ]] || return
_p9k_prompt_segment $0$_p9k_cache_val[10] magenta white KUBERNETES_ICON 0 '' "${_p9k_cache_val[9]//\%/%%}"
} }
_p9k_prompt_kubecontext_init() { _p9k_prompt_kubecontext_init() {

Loading…
Cancel
Save