Merge pull request #211 from dormunis/feature/eks-support
Added eks support for kubernetes prompt
This commit is contained in:
commit
038b1d4b6b
25
INSTALL.md
25
INSTALL.md
|
@ -326,6 +326,31 @@ set -g @dracula-clients-singular client
|
|||
set -g @dracula-clients-plural clients
|
||||
```
|
||||
|
||||
#### Kubernetes options
|
||||
|
||||
Add prefix label before the context
|
||||
|
||||
```bash
|
||||
set -g @dracula-kubernetes-context-label "Some Label"
|
||||
```
|
||||
|
||||
Hide user from the context string
|
||||
|
||||
```
|
||||
set -g @dracula-kubernetes-hide-user true
|
||||
```
|
||||
|
||||
Hide ARN (show only cluster name) - Available for EKS only (only available for cluster names that are ARNs)
|
||||
|
||||
```
|
||||
set -g @dracula-kubernetes-eks-hide-arn true
|
||||
```
|
||||
|
||||
Extract the account as a prefix to the cluster name - Available for EKS only (only available for cluster names that are ARNs)
|
||||
|
||||
```
|
||||
set -g @dracula-kubernetes-eks-extract-account true
|
||||
|
||||
#### continuum options
|
||||
|
||||
Set the output mode. Options are:
|
||||
|
|
|
@ -8,6 +8,10 @@ source $current_dir/utils.sh
|
|||
main()
|
||||
{
|
||||
# set configuration option variables
|
||||
show_kubernetes_context_label=$(get_tmux_option "@dracula-kubernetes-context-label" "")
|
||||
eks_hide_arn=$(get_tmux_option "@dracula-kubernetes-eks-hide-arn" false)
|
||||
eks_extract_account=$(get_tmux_option "@dracula-kubernetes-eks-extract-account" false)
|
||||
hide_kubernetes_user=$(get_tmux_option "@dracula-kubernetes-hide-user" false)
|
||||
terraform_label=$(get_tmux_option "@dracula-terraform-label" "")
|
||||
show_fahrenheit=$(get_tmux_option "@dracula-show-fahrenheit" true)
|
||||
show_location=$(get_tmux_option "@dracula-show-location" true)
|
||||
|
@ -25,7 +29,6 @@ main()
|
|||
show_refresh=$(get_tmux_option "@dracula-refresh-rate" 5)
|
||||
show_synchronize_panes_label=$(get_tmux_option "@dracula-synchronize-panes-label" "Sync")
|
||||
time_format=$(get_tmux_option "@dracula-time-format" "")
|
||||
show_kubernetes_context_label=$(get_tmux_option "@dracula-kubernetes-context-label" "")
|
||||
IFS=' ' read -r -a plugins <<< $(get_tmux_option "@dracula-plugins" "battery network weather")
|
||||
show_empty_plugins=$(get_tmux_option "@dracula-show-empty-plugins" true)
|
||||
|
||||
|
@ -206,7 +209,7 @@ main()
|
|||
|
||||
elif [ $plugin = "kubernetes-context" ]; then
|
||||
IFS=' ' read -r -a colors <<<$(get_tmux_option "@dracula-kubernetes-context-colors" "cyan dark_gray")
|
||||
script="#($current_dir/kubernetes_context.sh $show_kubernetes_context_label)"
|
||||
script="#($current_dir/kubernetes_context.sh $eks_hide_arn $eks_extract_account $hide_kubernetes_user $show_kubernetes_context_label)"
|
||||
|
||||
elif [ $plugin = "terraform" ]; then
|
||||
IFS=' ' read -r -a colors <<<$(get_tmux_option "@dracula-terraform-colors" "light_purple dark_gray")
|
||||
|
|
|
@ -2,7 +2,10 @@
|
|||
# setting the locale, some users have issues with different locales, this forces the correct one
|
||||
export LC_ALL=en_US.UTF-8
|
||||
|
||||
label=$1
|
||||
hide_arn_from_cluster=$1
|
||||
extract_account=$2
|
||||
hide_user=$3
|
||||
label=$4
|
||||
|
||||
current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
source $current_dir/utils.sh
|
||||
|
@ -12,11 +15,30 @@ current_user=$(kubectl config view --minify --output 'jsonpath={.contexts[?(@.na
|
|||
current_cluster=$(kubectl config view --minify --output 'jsonpath={.contexts[?(@.name=="'$current_context'")].context.cluster}'; echo)
|
||||
current_namespace=$(kubectl config view --minify --output 'jsonpath={.contexts[?(@.name=="'$current_context'")].context.namespace}'; echo)
|
||||
|
||||
current_account_id=""
|
||||
if [[ "$current_cluster" =~ ^arn:aws:eks:[a-z0-9\-]*:[0-9]*:cluster/[a-z0-9\-]*$ ]]; then
|
||||
if [ "$extract_account" = "true" ]; then
|
||||
current_account_id=$(echo "$current_cluster" | cut -d':' -f5)
|
||||
fi
|
||||
if [ "$hide_arn_from_cluster" = "true" ]; then
|
||||
current_cluster=${current_cluster##*/}
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$hide_user" = "true" ]; then
|
||||
current_user=""
|
||||
fi
|
||||
|
||||
main()
|
||||
{
|
||||
# storing the refresh rate in the variable RATE, default is 5
|
||||
RATE=$(get_tmux_option "@dracula-refresh-rate" 5)
|
||||
OUTPUT_STRING=""
|
||||
if [ ! -z "$current_account_id" ]
|
||||
then
|
||||
OUTPUT_STRING="${current_account_id}/"
|
||||
fi
|
||||
|
||||
if [ ! -z "$current_user" ]
|
||||
then
|
||||
OUTPUT_STRING="${current_user}@"
|
||||
|
|
Loading…
Reference in a new issue