Update kdjango

This commit is contained in:
Gabriel Augendre 2022-04-19 15:12:27 +02:00
parent 758cc61488
commit 80fde827a1

View file

@ -11,6 +11,11 @@ function kdjango --description 'Pop into the shell of django pod of the current
echo -e "\nRequires kubens for namespace selection" echo -e "\nRequires kubens for namespace selection"
return return
end end
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
set -l command /bin/bash set -l command /bin/bash
if set -q _flag_b if set -q _flag_b
set command /bin/bash set command /bin/bash
@ -21,12 +26,11 @@ function kdjango --description 'Pop into the shell of django pod of the current
else if set -q _flag_o else if set -q _flag_o
set command ./manage.py shell set command ./manage.py shell
else if set -q _flag_d else if set -q _flag_d
set command ./manage.py dbshell if kubectl exec -it $pod -- which pgcli &> /dev/null
end set command 'pgcli $(./manage.py sqldsn --quiet --style=uri)'
if count $argv > /dev/null else
set pod $argv[1] set command ./manage.py dbshell
else end
set pod (kubectl get pods -o name | grep "django" | grep -Ev "celery|migrations" | head -1)
end end
echo "running $command in $pod" echo "running $command in $pod"
kubectl exec -it $pod -- $command kubectl exec -it $pod -- $command