-
Notifications
You must be signed in to change notification settings - Fork 167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(cli): override kubectl path with env-var #221
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea is cool!
I wonder if it would be cleaner to have a function that returns a kubectl cmd with the correct binary set, instead of calling kubectlPath
in multiple places:
func kubectl(args ...string) *exec.Cmd {
binary := "kubectl"
if env := os.Getenv("TANKA_KUBECTL_PATH"); env != "" {
binary = env
}
return exec.Command(binary, args...)
}
Furthermore, env vars are not obvious from the CLI, we should document them at https://tanka.dev/env-vars |
@sh0rez definitely agree, this PR was a my first shot (after trying to do a (not-so) nice) dependency injection approach. Your approach is even nicer, let me re-work the PR and update the docs. |
Also, my original plan was to use CLI arguments for the override; this however proved quite clumsy given various places where |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Formatting nits, I'll fix myself. LGTM 🚀
Up to now, Tanka was using hard-coded string as a `kubectl` path, making it hard to do any other tool without playing tricks with $PATH. This commit allows to use TANKA_KUBECTL_PATH env variable to override the path to `kubectl` used in Tanka's code. See also #220 . Signed-off-by: Milan Plzik <milan.plzik@grafana.com>
As suggested in PR review, let's turn the `KubectlPath` into an actual function that returns exec.Command object. Signed-off-by: Milan Plzik <milan.plzik@grafana.com>
Signed-off-by: Milan Plzik <milan.plzik@grafana.com>
* `kubectlCmd` is only used within `client` package, no need for it to be public. * Nicer formatting of the environment variable documentation. Signed-off-by: Milan Plzik <milan.plzik@grafana.com>
49f0e18
to
e27e7b4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
Up to now, Tanka was using hard-coded string as a
kubectl
path, makingit hard to do any other tool without playing tricks with $PATH. This
commit allows to use TANKA_KUBECTL_PATH env variable to override the
path to
kubectl
used in Tanka's code.See also #220 .