forked from thecasualcoder/kube-fzf
-
Notifications
You must be signed in to change notification settings - Fork 4
/
krestart
executable file
·35 lines (30 loc) · 1.13 KB
/
krestart
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
31
32
33
34
35
#!/usr/bin/env bash
set -e
set -o pipefail
[[ -z "${KUBE_FZF_PATH}" ]] && source kube-fzf.sh || source $KUBE_FZF_PATH
rollout() {
local namespace_query pod_query result namespace rs_name
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 rollout restart $rs $rs_name --namespace='$namespace' --context '$context_selector'"
read -p "kubectl rollout restart $rs $rs_name --namespace='$namespace' --context '$context_selector' Are you Sure? " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
kubectl rollout restart $rs $rs_name --namespace=$namespace --context $context_selector
fi
}
rollout "$@"