summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAlan Pearce2019-03-23 13:27:28 +0100
committerAlan Pearce2019-03-23 13:28:00 +0100
commit20333b1b28d394eb5ef3341c0dbaf8183e0e55d7 (patch)
tree60af9c90a057d089fca57d17df64967d854a94fd
parent332ca22fd7c3011f158d50bc88a6cedc0fe0fa88 (diff)
downloaddotfiles-20333b1b28d394eb5ef3341c0dbaf8183e0e55d7.tar.lz
dotfiles-20333b1b28d394eb5ef3341c0dbaf8183e0e55d7.tar.zst
dotfiles-20333b1b28d394eb5ef3341c0dbaf8183e0e55d7.zip
zsh: Add kubernetes release detection
-rw-r--r--zsh/.config/zsh/.zshrc14
1 files changed, 14 insertions, 0 deletions
diff --git a/zsh/.config/zsh/.zshrc b/zsh/.config/zsh/.zshrc
index 0f7b014..ce28d65 100644
--- a/zsh/.config/zsh/.zshrc
+++ b/zsh/.config/zsh/.zshrc
@@ -218,8 +218,22 @@ else
   check_kubectl_context () {
     if [[ "$PWD" =~ /kubernetes ]]
     then
+      git_branch=$(git rev-parse --abbrev-ref HEAD)
       kubectl_context=$(kubectl config current-context)
       kubectl_namespace=$(kubectl config view -o jsonpath="{.contexts[?(@.name==\"${kubectl_context}\")].context.namespace}")
+      case $git_branch in
+        staging)
+          kubectl_release=satoshipay-${kubectl_namespace}-staging
+          ;;
+        production)
+          kubectl_release=satoshipay-${kubectl_namespace}
+          ;;
+        master)
+          kubectl_release=
+          ;;
+        *)
+          kubectl_release=story-${git_branch}-${kubectl_namespace}
+      esac
       if [[ $kubectl_context =~ production ]]
       then
         kubectl_colour=red