fix(misc plugins): split up multiline commands, use less -K everywhere (#2348)
`less -K` makes ctrl+c work with `less`. When running commands in k9s that use less, sometimes the command doesn't ever return or the user doesn't wait for it to finish. Issuing ctrl+c to a command with a simple `| less` puts k9s into an unfixable state, requiring restarting because `less` never quits. With `less -K`, ctrl+c quits `less` and the user should always be returned to a working `k9s` session. I also used multiline strings in a few places which improve readability and remove the need for double quotes in many places as many commands had gotten long.mine
parent
a52bbde956
commit
906138181e
|
|
@ -10,7 +10,7 @@ plugin:
|
|||
background: false
|
||||
args:
|
||||
- -c
|
||||
- "export FORCE_COLOR=1;kapp inspect -a $NAME.app --namespace $NAMESPACE --kubeconfig-context $CONTEXT --color --tty |& less -R"
|
||||
- "export FORCE_COLOR=1;kapp inspect -a $NAME.app --namespace $NAMESPACE --kubeconfig-context $CONTEXT --color --tty | less -RK"
|
||||
kctrl-app-status:
|
||||
shortCut: Shift-Q
|
||||
confirm: false
|
||||
|
|
@ -21,7 +21,7 @@ plugin:
|
|||
background: false
|
||||
args:
|
||||
- -c
|
||||
- "export FORCE_COLOR=1;kctrl app status -a $NAME --namespace $NAMESPACE --kubeconfig-context $CONTEXT --color --tty |& less -R"
|
||||
- "export FORCE_COLOR=1;kctrl app status -a $NAME --namespace $NAMESPACE --kubeconfig-context $CONTEXT --color --tty | less -RK"
|
||||
kctrl-app-pause:
|
||||
shortCut: Shift-T
|
||||
confirm: false
|
||||
|
|
@ -32,7 +32,7 @@ plugin:
|
|||
background: false
|
||||
args:
|
||||
- -c
|
||||
- "export FORCE_COLOR=1;kctrl app pause -a $NAME --namespace $NAMESPACE --kubeconfig-context $CONTEXT --yes --color --tty |& less -R"
|
||||
- "export FORCE_COLOR=1;kctrl app pause -a $NAME --namespace $NAMESPACE --kubeconfig-context $CONTEXT --yes --color --tty | less -RK"
|
||||
kctrl-app-kick:
|
||||
shortCut: Shift-Z
|
||||
confirm: false
|
||||
|
|
@ -43,5 +43,4 @@ plugin:
|
|||
background: false
|
||||
args:
|
||||
- -c
|
||||
- "export FORCE_COLOR=1;kctrl app kick -a $NAME --namespace $NAMESPACE --kubeconfig-context $CONTEXT --yes --color --tty |& less -R"
|
||||
|
||||
- "export FORCE_COLOR=1;kctrl app kick -a $NAME --namespace $NAMESPACE --kubeconfig-context $CONTEXT --yes --color --tty | less -RK"
|
||||
|
|
|
|||
|
|
@ -10,4 +10,12 @@ plugin:
|
|||
background: false
|
||||
args:
|
||||
- -c
|
||||
- "kubectl lineage -d 6 --exclude-types Event,ProviderConfigUsage.aws.upbound.io,ProviderConfigUsage.kubernetes.crossplane.io --show-group --context $CONTEXT $RESOURCE_NAME $NAME | less"
|
||||
- >-
|
||||
kubectl lineage
|
||||
-d 6
|
||||
--exclude-types Event,ProviderConfigUsage.aws.upbound.io,ProviderConfigUsage.kubernetes.crossplane.io
|
||||
--show-group
|
||||
--context $CONTEXT
|
||||
$RESOURCE_NAME
|
||||
$NAME
|
||||
| less -K
|
||||
|
|
|
|||
134
plugins/flux.yml
134
plugins/flux.yml
|
|
@ -13,7 +13,14 @@ plugin:
|
|||
background: false
|
||||
args:
|
||||
- -c
|
||||
- "flux --context $CONTEXT $([ $(kubectl --context $CONTEXT get helmreleases -n $NAMESPACE $NAME -o=custom-columns=TYPE:.spec.suspend | tail -1) = \"true\" ] && echo \"resume\" || echo \"suspend\") helmrelease -n $NAMESPACE $NAME |& less"
|
||||
- >-
|
||||
suspended=$(kubectl --context $CONTEXT get helmreleases -n $NAMESPACE $NAME -o=custom-columns=TYPE:.spec.suspend | tail -1);
|
||||
verb=$([ $suspended = "true" ] && echo "resume" || echo "suspend");
|
||||
flux
|
||||
$verb helmrelease
|
||||
--context $CONTEXT
|
||||
-n $NAMESPACE $NAME
|
||||
| less -K
|
||||
toggle-kustomization:
|
||||
shortCut: Shift-T
|
||||
confirm: true
|
||||
|
|
@ -24,29 +31,46 @@ plugin:
|
|||
background: false
|
||||
args:
|
||||
- -c
|
||||
- "flux --context $CONTEXT $([ $(kubectl --context $CONTEXT get kustomizations -n $NAMESPACE $NAME -o=custom-columns=TYPE:.spec.suspend | tail -1) = \"true\" ] && echo \"resume\" || echo \"suspend\") kustomization -n $NAMESPACE $NAME |& less"
|
||||
- >-
|
||||
suspended=$(kubectl --context $CONTEXT get kustomizations -n $NAMESPACE $NAME -o=custom-columns=TYPE:.spec.suspend | tail -1);
|
||||
verb=$([ $suspended = "true" ] && echo "resume" || echo "suspend");
|
||||
flux
|
||||
$verb kustomization
|
||||
--context $CONTEXT
|
||||
-n $NAMESPACE $NAME
|
||||
| less -K
|
||||
reconcile-git:
|
||||
shortCut: Shift-R
|
||||
confirm: false
|
||||
description: Flux reconcile
|
||||
scopes:
|
||||
- gitrepositories
|
||||
- gitrepositories
|
||||
command: bash
|
||||
background: false
|
||||
args:
|
||||
- -c
|
||||
- "flux --context $CONTEXT reconcile source git -n $NAMESPACE $NAME |& less"
|
||||
- -c
|
||||
- >-
|
||||
flux
|
||||
reconcile source git
|
||||
--context $CONTEXT
|
||||
-n $NAMESPACE $NAME
|
||||
| less -K
|
||||
reconcile-hr:
|
||||
shortCut: Shift-R
|
||||
confirm: false
|
||||
description: Flux reconcile
|
||||
scopes:
|
||||
- helmreleases
|
||||
- helmreleases
|
||||
command: bash
|
||||
background: false
|
||||
args:
|
||||
- -c
|
||||
- "flux --context $CONTEXT reconcile helmrelease -n $NAMESPACE $NAME |& less"
|
||||
- -c
|
||||
- >-
|
||||
flux
|
||||
reconcile helmrelease
|
||||
--context $CONTEXT
|
||||
-n $NAMESPACE $NAME
|
||||
| less -K
|
||||
reconcile-helm-repo:
|
||||
shortCut: Shift-Z
|
||||
description: Flux reconcile
|
||||
|
|
@ -57,7 +81,12 @@ plugin:
|
|||
confirm: false
|
||||
args:
|
||||
- -c
|
||||
- "flux reconcile source helm --context $CONTEXT -n $NAMESPACE $NAME |& less"
|
||||
- >-
|
||||
flux
|
||||
reconcile source helm
|
||||
--context $CONTEXT
|
||||
-n $NAMESPACE $NAME
|
||||
| less -K
|
||||
reconcile-oci-repo:
|
||||
shortCut: Shift-Z
|
||||
description: Flux reconcile
|
||||
|
|
@ -68,48 +97,109 @@ plugin:
|
|||
confirm: false
|
||||
args:
|
||||
- -c
|
||||
- "flux reconcile source oci --context $CONTEXT -n $NAMESPACE $NAME |& less"
|
||||
- >-
|
||||
flux
|
||||
reconcile source oci
|
||||
--context $CONTEXT
|
||||
-n $NAMESPACE $NAME
|
||||
| less -K
|
||||
reconcile-ks:
|
||||
shortCut: Shift-R
|
||||
confirm: false
|
||||
description: Flux reconcile
|
||||
scopes:
|
||||
- kustomizations
|
||||
- kustomizations
|
||||
command: bash
|
||||
background: false
|
||||
args:
|
||||
- -c
|
||||
- "flux --context $CONTEXT reconcile kustomization -n $NAMESPACE $NAME |& less"
|
||||
- -c
|
||||
- >-
|
||||
flux
|
||||
reconcile kustomization
|
||||
--context $CONTEXT
|
||||
-n $NAMESPACE $NAME
|
||||
| less -K
|
||||
reconcile-ir:
|
||||
shortCut: Shift-R
|
||||
confirm: false
|
||||
description: Flux reconcile
|
||||
scopes:
|
||||
- imagerepositories
|
||||
- imagerepositories
|
||||
command: sh
|
||||
background: false
|
||||
args:
|
||||
- -c
|
||||
- "flux --context $CONTEXT reconcile image repository -n $NAMESPACE $NAME | less"
|
||||
- -c
|
||||
- >-
|
||||
flux
|
||||
reconcile image repository
|
||||
--context $CONTEXT
|
||||
-n $NAMESPACE $NAME
|
||||
| less -K
|
||||
reconcile-iua:
|
||||
shortCut: Shift-R
|
||||
confirm: false
|
||||
description: Flux reconcile
|
||||
scopes:
|
||||
- imageupdateautomations
|
||||
- imageupdateautomations
|
||||
command: sh
|
||||
background: false
|
||||
args:
|
||||
- -c
|
||||
- "flux --context $CONTEXT reconcile image update -n $NAMESPACE $NAME | less"
|
||||
- -c
|
||||
- >-
|
||||
flux
|
||||
reconcile image update
|
||||
--context $CONTEXT
|
||||
-n $NAMESPACE $NAME
|
||||
| less -K
|
||||
trace:
|
||||
shortCut: Shift-A
|
||||
confirm: false
|
||||
description: Flux trace
|
||||
scopes:
|
||||
- all
|
||||
- all
|
||||
command: bash
|
||||
background: false
|
||||
args:
|
||||
- -c
|
||||
- "flux --context $CONTEXT trace --kind `echo $RESOURCE_NAME | sed -E 's/ies$/y/' | sed -E 's/ses$/se/' | sed -E 's/(s|es)$//g'` --api-version $RESOURCE_GROUP/$RESOURCE_VERSION --namespace $NAMESPACE $NAME |& less"
|
||||
- -c
|
||||
- >-
|
||||
resource=$(echo $RESOURCE_NAME | sed -E 's/ies$/y/' | sed -E 's/ses$/se/' | sed -E 's/(s|es)$//g')
|
||||
flux
|
||||
trace
|
||||
--context $CONTEXT
|
||||
--kind $resource
|
||||
--api-version $RESOURCE_GROUP/$RESOURCE_VERSION
|
||||
--namespace $NAMESPACE $NAME
|
||||
| less -K
|
||||
# credits: https://github.com/fluxcd/flux2/discussions/2494
|
||||
get-suspended-helmreleases:
|
||||
shortCut: Shift-S
|
||||
confirm: false
|
||||
description: Suspended Helm Releases
|
||||
scopes:
|
||||
- helmrelease
|
||||
command: sh
|
||||
background: false
|
||||
args:
|
||||
- -c
|
||||
- >-
|
||||
kubectl get
|
||||
--all-namespaces
|
||||
helmreleases.helm.toolkit.fluxcd.io -o json
|
||||
| jq -r '.items[] | select(.spec.suspend==true) | [.metadata.namespace,.metadata.name,.spec.suspend] | @tsv'
|
||||
| less
|
||||
get-suspended-kustomizations:
|
||||
shortCut: Shift-S
|
||||
confirm: false
|
||||
description: Suspended Kustomizations
|
||||
scopes:
|
||||
- kustomizations
|
||||
command: sh
|
||||
background: false
|
||||
args:
|
||||
- -c
|
||||
- >-
|
||||
kubectl get
|
||||
--all-namespaces
|
||||
kustomizations.kustomize.toolkit.fluxcd.io -o json
|
||||
| jq -r '.items[] | select(.spec.suspend==true) | [.metadata.name,.spec.suspend] | @tsv'
|
||||
| less
|
||||
|
|
|
|||
|
|
@ -5,20 +5,20 @@ plugin:
|
|||
confirm: false
|
||||
description: get-all
|
||||
scopes:
|
||||
- namespaces
|
||||
- namespaces
|
||||
command: sh
|
||||
background: false
|
||||
args:
|
||||
- -c
|
||||
- "kubectl get-all --context $CONTEXT -n $NAME | less"
|
||||
- -c
|
||||
- "kubectl get-all --context $CONTEXT -n $NAME | less -K"
|
||||
get-all-other:
|
||||
shortCut: g
|
||||
confirm: false
|
||||
description: get-all
|
||||
scopes:
|
||||
- all
|
||||
- all
|
||||
command: sh
|
||||
background: false
|
||||
args:
|
||||
- -c
|
||||
- "kubectl get-all --context $CONTEXT -n $NAMESPACE | less"
|
||||
- -c
|
||||
- "kubectl get-all --context $CONTEXT -n $NAMESPACE | less -K"
|
||||
|
|
|
|||
|
|
@ -1,23 +0,0 @@
|
|||
# credits: https://github.com/fluxcd/flux2/discussions/2494
|
||||
get-suspended-helmreleases:
|
||||
shortCut: Shift-S
|
||||
confirm: false
|
||||
description: Suspended Helm Releases
|
||||
scopes:
|
||||
- helmrelease
|
||||
command: sh
|
||||
background: false
|
||||
args:
|
||||
- -c
|
||||
- "kubectl get --all-namespaces helmreleases.helm.toolkit.fluxcd.io -o json | jq -r '.items[] | select(.spec.suspend==true) | [.metadata.namespace,.metadata.name,.spec.suspend] | @tsv' | less"
|
||||
get-suspended-kustomizations:
|
||||
shortCut: Shift-S
|
||||
confirm: false
|
||||
description: Suspended Kustomizations
|
||||
scopes:
|
||||
- kustomizations
|
||||
command: sh
|
||||
background: false
|
||||
args:
|
||||
- -c
|
||||
- "kubectl get --all-namespaces kustomizations.kustomize.toolkit.fluxcd.io -o json | jq -r '.items[] | select(.spec.suspend==true) | [.metadata.name,.spec.suspend] | @tsv' | less"
|
||||
|
|
@ -9,5 +9,17 @@ plugin:
|
|||
background: false
|
||||
args:
|
||||
- -c
|
||||
- "kubectl get secrets --context $CONTEXT -n $NAMESPACE sh.helm.release.v1.$COL-NAME.v$(helm history -n $NAMESPACE --kube-context $CONTEXT $COL-NAME | grep deployed | cut -d$'\\t' -f1 | tr -d ' \\t') -o yaml | yq e '.data.release' - | base64 -d | base64 -d | gunzip | jq -r '.chart.values' | yq -P | less"
|
||||
|
||||
- >-
|
||||
revision=$(helm history -n $NAMESPACE --kube-context $CONTEXT $COL-NAME | grep deployed | cut -d$'\t' -f1 | tr -d ' \t');
|
||||
kubectl
|
||||
get secrets
|
||||
--context $CONTEXT
|
||||
-n $NAMESPACE
|
||||
sh.helm.release.v1.$COL-NAME.v$revision -o yaml
|
||||
| yq e '.data.release' -
|
||||
| base64 -d
|
||||
| base64 -d
|
||||
| gunzip
|
||||
| jq -r '.chart.values'
|
||||
| yq -P
|
||||
| less -K
|
||||
|
|
|
|||
|
|
@ -6,9 +6,9 @@ plugin:
|
|||
confirm: false
|
||||
description: Values
|
||||
scopes:
|
||||
- helm
|
||||
- helm
|
||||
command: sh
|
||||
background: false
|
||||
args:
|
||||
- -c
|
||||
- "helm get values $COL-NAME -n $NAMESPACE --kube-context $CONTEXT | less"
|
||||
- -c
|
||||
- "helm get values $COL-NAME -n $NAMESPACE --kube-context $CONTEXT | less -K"
|
||||
|
|
|
|||
Loading…
Reference in New Issue