Skip to content

Commit

Permalink
Merge pull request #285 from josepedropereira/feature/show-only-kube-…
Browse files Browse the repository at this point in the history
…context

Add new kubernetes option to just show the context name
  • Loading branch information
ethancedwards8 authored Sep 3, 2024
2 parents 415927f + c3962d8 commit bbad087
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
3 changes: 2 additions & 1 deletion scripts/dracula.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ main()
{
# set configuration option variables
show_kubernetes_context_label=$(get_tmux_option "@dracula-kubernetes-context-label" "")
show_only_kubernetes_context=$(get_tmux_option "@dracula-show-only-kubernetes-context" "")
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)
Expand Down Expand Up @@ -231,7 +232,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 $eks_hide_arn $eks_extract_account $hide_kubernetes_user $show_kubernetes_context_label)"
script="#($current_dir/kubernetes_context.sh $eks_hide_arn $eks_extract_account $hide_kubernetes_user $show_only_kubernetes_context $show_kubernetes_context_label)"

elif [ $plugin = "terraform" ]; then
IFS=' ' read -r -a colors <<<$(get_tmux_option "@dracula-terraform-colors" "light_purple dark_gray")
Expand Down
18 changes: 15 additions & 3 deletions scripts/kubernetes_context.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ export LC_ALL=en_US.UTF-8
hide_arn_from_cluster=$1
extract_account=$2
hide_user=$3
label=$4
just_current_context=$4
label=$5

current_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source $current_dir/utils.sh
Expand Down Expand Up @@ -34,6 +35,19 @@ main()
# storing the refresh rate in the variable RATE, default is 5
RATE=$(get_tmux_option "@dracula-refresh-rate" 5)
OUTPUT_STRING=""

if [ "$just_current_context" = "true" ]
then
echo "$current_context"
else
getFullMessage
fi

sleep $RATE
}

getFullMessage()
{
if [ ! -z "$current_account_id" ]
then
OUTPUT_STRING="${current_account_id}/"
Expand Down Expand Up @@ -65,8 +79,6 @@ main()
else
echo "${label} ${OUTPUT_STRING}"
fi

sleep $RATE
}

# run the main driver
Expand Down

0 comments on commit bbad087

Please sign in to comment.