kubectl-confirm
kubectl-confirm copied to clipboard
Only prompt for specific contexts
What would you like to be added:
This specifically pertains to the situation where one would alias kubectl=kubectl confirm
however, it would be great if this could have a configuration available to only prompt when running against specific cluster contexts or for specific subcommands.
Why is this needed:
This could help protect only commands that modify the cluster and only do it on clusters that matter. Consider the situation where you might have a dev cluster and a production cluster in your contexts. Generally, I am okay with firing off on prompted commands against the dev cluster because I am usually exploring or testing changes to the cluster and like to move fast. However, sometimes I have my context set to prod and this is really when I want to be prompted. By making the prompts context specific it can help avoid the habit of just slamming yes
into the prompt.
Likewise with specific subcommands. I don't really need to confirm that I want to run a kubectl get pods
however, kubectl delete pods
would be valuable to be prompted for.
I would think a small config file mapping context names to commands should be sufficient. If the context is in the file and the command is in the list of prompts then prompt. Otherwise, just passthrough as though it was a vanilla kubectl
command.
ie:
prod-context-name:
command:
- apply
- delete
- rollout