Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix kubectl tab-completion and improve error messages
Try to fix the following issues when `kubectl` is an alias for `minikube kubectl --` and tab-completion for `kubectl` is enabled: 1. When `--cluster name` form of command-line option is used, it conflicts with argument parsing, `name` is interpreted as plugin name. Call to `kubectl --cluster test help` leads to error `Error: flags cannot be placed before plugin name: --cluster`. Fix this by using `--cluster=name` form, which is correctly handled also in call `kubectl --cluster=test help`. 2. When `--cluster=name` is added as first argument (as seen in original code), it still leads to error mentioned above when the command is unknown like in the call `kubectl --cluster=test unknown`. Fix this by inserting `--cluster=name` after all (sub-)commands and before any flags/options. 3. The original code passed `--cluster=name` to normal `kubectl` calls, but omitted it for tab-completion calls. This might lead to wrong tab suggestions about pods, deployments and the like. Fix this by always adding `--cluster=name` option to the command line. 4. In case of tab-completion, put the `--cluster=name` immediately after `__complete` command to prevent any interference with incomplete commands (just in case). This works fine and does not generate any errors like mentioned in point 2.