Commit 14efdee0 authored by Matt Butcher's avatar Matt Butcher

fix(cli): switched `server` actions to use `run()`

parent 084c0da5
...@@ -19,7 +19,6 @@ package main ...@@ -19,7 +19,6 @@ package main
import ( import (
"errors" "errors"
"fmt" "fmt"
"os"
"github.com/codegangsta/cli" "github.com/codegangsta/cli"
"github.com/kubernetes/helm/pkg/client" "github.com/kubernetes/helm/pkg/client"
...@@ -68,16 +67,7 @@ func dmCmd() cli.Command { ...@@ -68,16 +67,7 @@ func dmCmd() cli.Command {
EnvVar: "HELM_MANAGER_IMAGE", EnvVar: "HELM_MANAGER_IMAGE",
}, },
}, },
Action: func(c *cli.Context) { Action: func(c *cli.Context) { run(c, installServer) },
dry := c.Bool("dry-run")
ri := c.String("resourcifier-image")
ei := c.String("expandybird-image")
mi := c.String("manager-image")
if err := install(dry, ei, mi, ri); err != nil {
format.Err("%s (Run 'helm doctor' for more information)", err)
os.Exit(1)
}
},
}, },
{ {
Name: "uninstall", Name: "uninstall",
...@@ -90,12 +80,7 @@ func dmCmd() cli.Command { ...@@ -90,12 +80,7 @@ func dmCmd() cli.Command {
Usage: "Show what would be uninstalled, but don't remove anything.", Usage: "Show what would be uninstalled, but don't remove anything.",
}, },
}, },
Action: func(c *cli.Context) { Action: func(c *cli.Context) { run(c, uninstallServer) },
if err := uninstall(c.Bool("dry-run")); err != nil {
format.Err("%s (Run 'helm doctor' for more information)", err)
os.Exit(1)
}
},
}, },
{ {
Name: "status", Name: "status",
...@@ -107,22 +92,13 @@ func dmCmd() cli.Command { ...@@ -107,22 +92,13 @@ func dmCmd() cli.Command {
Usage: "Only display the underlying kubectl commands.", Usage: "Only display the underlying kubectl commands.",
}, },
}, },
Action: func(c *cli.Context) { Action: func(c *cli.Context) { run(c, statusServer) },
if err := status(c.Bool("dry-run")); err != nil {
os.Exit(1)
}
},
}, },
{ {
Name: "target", Name: "target",
Usage: "Displays information about the Kubernetes cluster.", Usage: "Displays information about the Kubernetes cluster.",
ArgsUsage: "", ArgsUsage: "",
Action: func(c *cli.Context) { Action: func(c *cli.Context) { run(c, targetServer) },
if err := target(c.Bool("dry-run")); err != nil {
format.Err("%s (Is the cluster running?)", err)
os.Exit(1)
}
},
Flags: []cli.Flag{ Flags: []cli.Flag{
cli.BoolFlag{ cli.BoolFlag{
Name: "dry-run", Name: "dry-run",
...@@ -134,7 +110,11 @@ func dmCmd() cli.Command { ...@@ -134,7 +110,11 @@ func dmCmd() cli.Command {
} }
} }
func install(dryRun bool, ebImg, manImg, resImg string) error { func installServer(c *cli.Context) error {
dryRun := c.Bool("dry-run")
resImg := c.String("resourcifier-image")
ebImg := c.String("expandybird-image")
manImg := c.String("manager-image")
runner := getKubectlRunner(dryRun) runner := getKubectlRunner(dryRun)
i := client.NewInstaller() i := client.NewInstaller()
...@@ -146,11 +126,14 @@ func install(dryRun bool, ebImg, manImg, resImg string) error { ...@@ -146,11 +126,14 @@ func install(dryRun bool, ebImg, manImg, resImg string) error {
if err != nil { if err != nil {
return err return err
} }
format.Msg(out) if debug {
format.Msg(out)
}
return nil return nil
} }
func uninstall(dryRun bool) error { func uninstallServer(c *cli.Context) error {
dryRun := c.Bool("dry-run")
runner := getKubectlRunner(dryRun) runner := getKubectlRunner(dryRun)
out, err := client.Uninstall(runner) out, err := client.Uninstall(runner)
...@@ -161,7 +144,8 @@ func uninstall(dryRun bool) error { ...@@ -161,7 +144,8 @@ func uninstall(dryRun bool) error {
return nil return nil
} }
func status(dryRun bool) error { func statusServer(c *cli.Context) error {
dryRun := c.Bool("dry-run")
client := kubectl.Client client := kubectl.Client
if dryRun { if dryRun {
client = kubectl.PrintRunner{} client = kubectl.PrintRunner{}
...@@ -182,7 +166,8 @@ func getKubectlRunner(dryRun bool) kubectl.Runner { ...@@ -182,7 +166,8 @@ func getKubectlRunner(dryRun bool) kubectl.Runner {
return &kubectl.RealRunner{} return &kubectl.RealRunner{}
} }
func target(dryRun bool) error { func targetServer(c *cli.Context) error {
dryRun := c.Bool("dry-run")
client := kubectl.Client client := kubectl.Client
if dryRun { if dryRun {
client = kubectl.PrintRunner{} client = kubectl.PrintRunner{}
......
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