Created
March 15, 2019 23:40
-
-
Save jazzdan/d30ef73482920beb3ac9fa2fcb2c3146 to your computer and use it in GitHub Desktop.
Tiltfile that checks kube context against safe list
This file contains 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
{ | |
"allowed_context": "minikube" | |
} |
This file contains 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
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