forked from thecasualcoder/kube-fzf
-
Notifications
You must be signed in to change notification settings - Fork 4
/
kdesc
executable file
·30 lines (25 loc) · 965 Bytes
/
kdesc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env bash
set -e
set -o pipefail
[[ -z "${KUBE_FZF_PATH}" ]] && source kube-fzf.sh || source $KUBE_FZF_PATH
desc() {
local namespace_query pod_query result namespace rs_name context
local rs=$1
if [[ $rs == *"-"* ]] || [ -z "$rs" ]; then
rs=$(kube_fzf_api_resources)
if [ -z "$rs" ]; then
exit
fi
_kube_fzf_handler "kdesc" "$@"
else
_kube_fzf_handler "kdesc" "$2" "$3" "$4" "$5" "$6"
fi
namespace_query=$(echo $args | awk -F '|' '{ print $1 }')
pod_query=$(echo $args | awk -F '|' '{ print $2 }')
context_selector=$(echo $args | awk -F '|' '{ print $5 }')
result=$(_kube_fzf_search "$namespace_query" "$pod_query" "$context_selector" "$rs")
IFS=$'|' read -r namespace rs_name <<< "$result"
_kube_fzf_echo "kubectl describe $rs $rs_name --namespace='$namespace' --context '$context_selector'"
kubectl describe $rs $rs_name --namespace=$namespace --context $context_selector
}
desc "$@"