Skip to content

Commit

Permalink
confirm dialog for potentially dangerous actions.
Browse files Browse the repository at this point in the history
  • Loading branch information
pymag09 committed Jul 16, 2024
1 parent 9aea06d commit 9926cd4
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion fx/daemonsets/config
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ HEADER='========================================================================
Scrolling (SHIFT - up/down) || CTRL-/ (change view) || CTRL-R (refresh. omit -o wide) || Ctrl-L (-o wide)
=========================================================================================================='

PARAMS+=(--bind "f2:execute:kubectl --namespace {1} rollout restart ${RS_TYPE} {2}")
PARAMS+=(--bind "f2:execute:confirm && kubectl --namespace {1} rollout restart ${RS_TYPE} {2}")
PARAMS+=(--bind "f6:execute:trivy_scan_manifest {1} {2} ${RS_TYPE}")
PARAMS+=(--bind "f7:execute:trivy_scan_image {1} {2} ${RS_TYPE}")
2 changes: 1 addition & 1 deletion fx/default/config
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ PARAMS+=(--bind "f1:execute:explain_obj ${RS_TYPE}")
PARAMS+=(--bind "f3:execute:kubectl get $RS_TYPE ${SCOPED:+"{2} -n {1}"}${NONSCOPED:-"{1}"} -o yaml | less")
PARAMS+=(--bind "f4:execute:kubectl edit $RS_TYPE ${SCOPED:+"{2} -n {1}"}${NONSCOPED:-"{1}"}")
PARAMS+=(--bind "f5:execute:kubectl describe $RS_TYPE ${SCOPED:+"{2} -n {1}"}${NONSCOPED:-"{1}"} | less")
PARAMS+=(--bind "f8:execute:kubectl delete $RS_TYPE ${SCOPED:+"{2} -n {1}"}${NONSCOPED:-"{1}"}")
PARAMS+=(--bind "f8:execute:confirm && kubectl delete $RS_TYPE ${SCOPED:+"{2} -n {1}"}${NONSCOPED:-"{1}"}")
1 change: 1 addition & 0 deletions fx/libs/confirm.entrypoint
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
confirm
4 changes: 4 additions & 0 deletions fx/libs/confirm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
confirm()
{
[ "$(echo -e "No\nYes" | fzf --border=double --border-label="╢ Confirmation ╟" --margin 40% --prompt 'Are you sure? ')" == "Yes" ]
}
2 changes: 1 addition & 1 deletion fx/nodes/config
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ Scrolling (SHIFT - up/down) || CTRL-/ (change view) || CTRL-R (refresh. omit -o
PARAMS+=(--bind 'f2:execute:node-shell {1}')
PARAMS+=(--bind 'f6:execute:kubectl cordon {1}')
PARAMS+=(--bind 'f7:execute:kubectl uncordon {1}')
PARAMS+=(--bind 'f9:execute:kubectl drain {1} --ignore-daemonsets --delete-emptydir-data')
PARAMS+=(--bind 'f9:execute:confirm && kubectl drain {1} --ignore-daemonsets --delete-emptydir-data')
PARAMS+=(--bind 'f10:execute:kubent -t $(kubectl version -o yaml | yq .serverVersion.major).$(($(kubectl version -o yaml | yq .serverVersion.minor | sed -E "s/^([0-9]+).*/\1/") + 1)).0 | less -R --use-color')

0 comments on commit 9926cd4

Please sign in to comment.