Commit 22c6b9b2 authored by Adam Reese's avatar Adam Reese

Merge pull request #8 from adamreese/dm-uninstall

feat(dm-delete): add dm-delete command
parents a3166a9c 1e37113c
......@@ -11,15 +11,8 @@ import (
var ErrAlreadyInstalled error = errors.New("Already Installed")
func install(dryRun bool) error {
var runner kubectl.Runner
if dryRun {
runner = &kubectl.PrintRunner{}
} else {
runner = &kubectl.RealRunner{}
if dm.IsInstalled(runner) {
return ErrAlreadyInstalled
}
}
runner := getKubectlRunner(dryRun)
out, err := dm.Install(runner)
if err != nil {
format.Error("Error installing: %s %s", out, err)
......@@ -27,3 +20,21 @@ func install(dryRun bool) error {
format.Msg(out)
return nil
}
func uninstall(dryRun bool) error {
runner := getKubectlRunner(dryRun)
out, err := dm.Uninstall(runner)
if err != nil {
format.Error("Error uninstalling: %s %s", out, err)
}
format.Msg(out)
return nil
}
func getKubectlRunner(dryRun bool) kubectl.Runner {
if dryRun {
return &kubectl.PrintRunner{}
}
return &kubectl.RealRunner{}
}
......@@ -33,8 +33,12 @@ func main() {
func commands() []cli.Command {
return []cli.Command{
{
Name: "init",
Usage: "Initialize the client and install DM on Kubernetes.",
Name: "dm",
Usage: "Manage DM on Kubernetes",
Subcommands: []cli.Command{
{
Name: "install",
Usage: "Install DM on Kubernetes.",
Description: ``,
Flags: []cli.Flag{
cli.BoolFlag{
......@@ -49,6 +53,31 @@ func commands() []cli.Command {
}
},
},
{
Name: "uninstall",
Usage: "Uninstall the DM from Kubernetes.",
Description: ``,
Flags: []cli.Flag{
cli.BoolFlag{
Name: "dry-run",
Usage: "Show what would be installed, but don't install anything.",
},
},
Action: func(c *cli.Context) {
if err := uninstall(c.Bool("dry-run")); err != nil {
format.Error("%s (Run 'helm doctor' for more information)", err)
os.Exit(1)
}
},
},
{
Name: "status",
Usage: "Show status of DM.",
Action: func(c *cli.Context) {
format.Error("Not yet implemented")
os.Exit(1)
},
},
{
Name: "target",
Usage: "Displays information about cluster.",
......@@ -66,6 +95,25 @@ func commands() []cli.Command {
},
},
},
},
},
{
Name: "init",
Usage: "Initialize the client and install DM on Kubernetes.",
Description: ``,
Flags: []cli.Flag{
cli.BoolFlag{
Name: "dry-run",
Usage: "Show what would be installed, but don't install anything.",
},
},
Action: func(c *cli.Context) {
if err := install(c.Bool("dry-run")); err != nil {
format.Error("%s (Run 'helm doctor' for more information)", err)
os.Exit(1)
}
},
},
{
Name: "doctor",
Usage: "Run a series of checks for necessary prerequisites.",
......
package dm
import (
"github.com/deis/helm-dm/kubectl"
)
// uninstall uses kubectl to uninstall the base DM.
//
// Returns the string output received from the operation, and an error if the
// command failed.
func Uninstall(runner kubectl.Runner) (string, error) {
o, err := runner.Delete("dm", "Namespace", "dm")
return string(o), err
}
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