From 3ef5c7fd3cd6007249fd2e8f8da93649818f0a05 Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Mon, 4 Apr 2022 13:31:17 +0200 Subject: [PATCH] Allow passing pod to kdjango --- dot_config/fish/private_functions/private_kdjango.fish | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/dot_config/fish/private_functions/private_kdjango.fish b/dot_config/fish/private_functions/private_kdjango.fish index a7afb66..566878c 100644 --- a/dot_config/fish/private_functions/private_kdjango.fish +++ b/dot_config/fish/private_functions/private_kdjango.fish @@ -1,6 +1,6 @@ # Defined interactively function kdjango --description 'Pop into the shell of django pod of the current namespace' - argparse -x "h,b,s,m,o,d" "h/help" "b/bash" "s/sh" "m/manage" "o/original-shell" "d/db-shell" -- $argv; or return + argparse -X 1 -x "h,b,s,m,o,d" "h/help" "b/bash" "s/sh" "m/manage" "o/original-shell" "d/db-shell" -- $argv; or return if set -q _flag_h echo "Exec into the django pod of the current namespace..." echo -e "kdjango [-b]\t ...using bash (default if no option)" @@ -23,7 +23,11 @@ function kdjango --description 'Pop into the shell of django pod of the current else if set -q _flag_d set command ./manage.py dbshell end - set pod (kubectl get pods -o name | grep "django" | grep -Ev "celery|migrations" | head -1) + if count $argv > /dev/null + set pod $argv[1] + else + set pod (kubectl get pods -o name | grep "django" | grep -Ev "celery|migrations" | head -1) + end echo "running $command in $pod" kubectl exec -it $pod -- $command end