From bd5980a5d7433fd0ec81bd270c9d58e506ede54b Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Sat, 23 Jun 2018 18:07:56 +0200 Subject: feat(main): Add CLI flag for setting kubectl executable This lets users choose the executable (either by full path or via a $PATH-entry) to be used when executing `kubectl`. This is useful in, for example, OpenShift based setups. This fixes #143 --- main.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'main.go') diff --git a/main.go b/main.go index a943976195..ca20bb76b0 100644 --- a/main.go +++ b/main.go @@ -35,9 +35,10 @@ var ( app = kingpin.New("kontemplate", "simple Kubernetes resource templating") // Global flags - includes = app.Flag("include", "Resource sets to include explicitly").Short('i').Strings() - excludes = app.Flag("exclude", "Resource sets to exclude explicitly").Short('e').Strings() - variables = app.Flag("var", "Provide variables to templates explicitly").Strings() + includes = app.Flag("include", "Resource sets to include explicitly").Short('i').Strings() + excludes = app.Flag("exclude", "Resource sets to exclude explicitly").Short('e').Strings() + variables = app.Flag("var", "Provide variables to templates explicitly").Strings() + kubectlBin = app.Flag("kubectl", "Path to the kubectl binary (default 'kubectl')").Default("kubectl").String() // Commands template = app.Command("template", "Template resource sets and print them") @@ -206,7 +207,7 @@ func runKubectlWithResources(c *context.Context, kubectlArgs *[]string, resource continue } - kubectl := exec.Command("kubectl", args...) + kubectl := exec.Command(*kubectlBin, args...) stdin, err := kubectl.StdinPipe() if err != nil { -- cgit 1.4.1