mirror of
https://github.com/ahmetb/kubectx.git
synced 2025-06-25 06:51:55 +00:00
Support "kubectx NAME=." to rename current-context
Fixes #24. Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>
This commit is contained in:
parent
fbce3de6b9
commit
0141d66224
5
kubectx
5
kubectx
@ -30,6 +30,7 @@ USAGE:
|
|||||||
kubectx <NAME> : switch to context <NAME>
|
kubectx <NAME> : switch to context <NAME>
|
||||||
kubectx - : switch to the previous context
|
kubectx - : switch to the previous context
|
||||||
kubectx <NEW_NAME>=<NAME> : rename context <NAME> to <NEW_NAME>
|
kubectx <NEW_NAME>=<NAME> : rename context <NAME> to <NEW_NAME>
|
||||||
|
kubectx <NEW_NAME>=. : rename current-context to <NEW_NAME>
|
||||||
kubectx -h,--help : show this message
|
kubectx -h,--help : show this message
|
||||||
EOF
|
EOF
|
||||||
exit 1
|
exit 1
|
||||||
@ -122,6 +123,10 @@ rename_context() {
|
|||||||
local old_name="${1}"
|
local old_name="${1}"
|
||||||
local new_name="${2}"
|
local new_name="${2}"
|
||||||
|
|
||||||
|
if [[ "${old_name}" == "." ]]; then
|
||||||
|
old_name="$(current_context)"
|
||||||
|
fi
|
||||||
|
|
||||||
# TODO(ahmetb) old_user and old_cluster are no longer used, clean up
|
# TODO(ahmetb) old_user and old_cluster are no longer used, clean up
|
||||||
local old_user old_cluster
|
local old_user old_cluster
|
||||||
old_user="$(user_of_context "${old_name}")"
|
old_user="$(user_of_context "${old_name}")"
|
||||||
|
Loading…
Reference in New Issue
Block a user