Created
July 7, 2020 14:49
-
-
Save mwpeterson/cb4fb808900032b8a0ef24b63c8fe9e7 to your computer and use it in GitHub Desktop.
function kctx()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function kctx() { | |
_die() { | |
printf '%s\n' "$1" >&2 | |
return 1 | |
} | |
context="$1" | |
context_config_dir="$HOME/.kube/ctxcfg" | |
if [ -f "${context_config_dir}/${context}" ] ; then | |
export KUBECONFIG="${context_config_dir}/${context}" | |
else | |
echo "Specify a context: kctx <context>" | |
ls -1 $context_config_dir | |
_die "${context} not found in ${context_config_dir}" | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment