Skip to content

Commit

Permalink
Support "kubectx NAME=." to rename current-context
Browse files Browse the repository at this point in the history
Fixes #24.

Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>
  • Loading branch information
ahmetb committed Apr 3, 2018
1 parent fbce3de commit 0141d66
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions kubectx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}")"
Expand Down

0 comments on commit 0141d66

Please sign in to comment.