Support "kubectx NAME=." to rename current-context

Fixes #24.

Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>
This commit is contained in:
Ahmet Alp Balkan 2018-04-02 23:52:18 -07:00
parent fbce3de6b9
commit 0141d66224
No known key found for this signature in database
GPG Key ID: 5C02521D7B216AD6

View File

@ -30,6 +30,7 @@ USAGE:
kubectx <NAME> : switch to context <NAME>
kubectx - : switch to the previous context
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
EOF
exit 1
@ -122,6 +123,10 @@ rename_context() {
local old_name="${1}"
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
local old_user old_cluster
old_user="$(user_of_context "${old_name}")"