Commit d32c20fd authored by Adam Reese's avatar Adam Reese

ref(cmd): move flags out of init()

parent eee6e143
......@@ -63,30 +63,35 @@ Environment:
$HELM_HOST Set an alternative Tiller host. The format is host:port (default ":44134").
`
// RootCommand is the top-level command for Helm.
var RootCommand = &cobra.Command{
Use: "helm",
Short: "The Helm package manager for Kubernetes.",
Long: globalUsage,
PersistentPostRun: teardown,
SilenceUsage: true,
}
func init() {
func newRootCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "helm",
Short: "The Helm package manager for Kubernetes.",
Long: globalUsage,
SilenceUsage: true,
PersistentPostRun: func(cmd *cobra.Command, args []string) {
teardown()
},
}
home := os.Getenv(homeEnvVar)
if home == "" {
home = "$HOME/.helm"
}
thost := os.Getenv(hostEnvVar)
p := RootCommand.PersistentFlags()
p := cmd.PersistentFlags()
p.StringVar(&helmHome, "home", home, "location of your Helm config. Overrides $HELM_HOME.")
p.StringVar(&tillerHost, "host", thost, "address of tiller. Overrides $HELM_HOST.")
p.StringVarP(&tillerNamespace, "namespace", "", "", "kubernetes namespace")
p.BoolVarP(&flagDebug, "debug", "", false, "enable verbose output")
return cmd
}
// RootCommand is the top-level command for Helm.
var RootCommand = newRootCmd()
func main() {
if err := RootCommand.Execute(); err != nil {
cmd := RootCommand
if err := cmd.Execute(); err != nil {
os.Exit(1)
}
}
......@@ -112,7 +117,7 @@ func setupConnection(c *cobra.Command, args []string) error {
return nil
}
func teardown(c *cobra.Command, args []string) {
func teardown() {
if tunnel != nil {
tunnel.Close()
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment