about summary refs log tree commit diff
path: root/main.go
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2018-06-23T16·07+0200
committerVincent Ambo <github@tazj.in>2018-06-26T10·29+0200
commitbd5980a5d7433fd0ec81bd270c9d58e506ede54b (patch)
tree506885ace18ac67c19af355b7d5cb4dd66ecfe60 /main.go
parent92c5c846e2ce19c4c46a70a36c533245538c2dd3 (diff)
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
Diffstat (limited to 'main.go')
-rw-r--r--main.go9
1 files changed, 5 insertions, 4 deletions
diff --git a/main.go b/main.go
index a94397619561..ca20bb76b0bb 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 {