diff --git a/cmd/helm/delete.go b/cmd/helm/delete.go new file mode 100644 index 000000000..b954dfe03 --- /dev/null +++ b/cmd/helm/delete.go @@ -0,0 +1,33 @@ +package main + +import ( + "errors" + + "github.com/codegangsta/cli" + "github.com/deis/helm-dm/format" +) + +func init() { + addCommands(deleteCmd()) +} + +func deleteCmd() cli.Command { + return cli.Command{ + Name: "delete", + Usage: "Deletes the supplied deployment", + Action: func(c *cli.Context) { run(c, deleteDeployment) }, + } +} + +func deleteDeployment(c *cli.Context) error { + args := c.Args() + if len(args) < 1 { + return errors.New("First argument, deployment name, is required. Try 'helm get --help'") + } + name := args[0] + deployment, err := client(c).DeleteDeployment(name) + if err != nil { + return err + } + return format.YAML(deployment) +} diff --git a/dm/client.go b/dm/client.go index 217508b05..456fecbbb 100644 --- a/dm/client.go +++ b/dm/client.go @@ -224,3 +224,12 @@ func (c *Client) GetDeployment(name string) (*common.Deployment, error) { } return deployment, nil } + +// DeleteDeployment deletes the supplied deployment +func (c *Client) DeleteDeployment(name string) (*common.Deployment, error) { + var deployment *common.Deployment + if err := c.CallService(filepath.Join("deployments", name), "DELETE", "delete deployment", &deployment, nil); err != nil { + return nil, err + } + return deployment, nil +}