Skip to content

Instantly share code, notes, and snippets.

@jazzdan
Created March 15, 2019 23:40
Show Gist options
  • Save jazzdan/d30ef73482920beb3ac9fa2fcb2c3146 to your computer and use it in GitHub Desktop.
Save jazzdan/d30ef73482920beb3ac9fa2fcb2c3146 to your computer and use it in GitHub Desktop.
Tiltfile that checks kube context against safe list
{
"allowed_context": "minikube"
}
settings = read_json(".tilt.json")
def enforce_context(allowed_context):
if allowed_context == "":
return
current_context = str(local('kubectl config current-context')).rstrip('\n')
if current_context != allowed_context:
fail("Context %s is not allowed. Only the %s context is allowed." % (current_context, allowed_context))
allowed_context = settings.get("allowed_context", "")
enforce_context(allowed_context)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment