Skip to content

Instantly share code, notes, and snippets.

@billglover
Created June 10, 2020 19:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save billglover/b1b47a458673ceebd0e1d95bcb33ad11 to your computer and use it in GitHub Desktop.
Save billglover/b1b47a458673ceebd0e1d95bcb33ad11 to your computer and use it in GitHub Desktop.
Set the KUBECONFIG envar with all YAML files in the specified folder.
#!/bin/sh
DEFAULT_CONTEXTS="$HOME/.kube/config"
if test -f "${DEFAULT_CONTEXTS}"
then
export KUBECONFIG="$DEFAULT_CONTEXTS"
fi
CUSTOM_CONTEXTS="$HOME/.kube/custom-contexts"
mkdir -p "${CUSTOM_CONTEXTS}"
OIFS="$IFS"
IFS=$'\n'
for file in `find "${CUSTOM_CONTEXTS}" -type f -name "*.yml" -or -name "*.yaml"`
do
export KUBECONFIG="$file:$KUBECONFIG"
done
IFS="$OIFS"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment