Commit dbd90b5c authored by Adam Reese's avatar Adam Reese

feat(delete): add delete verb

parent a2e928ad
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)
}
...@@ -13,7 +13,7 @@ var version = "0.0.1" ...@@ -13,7 +13,7 @@ var version = "0.0.1"
var commands []cli.Command var commands []cli.Command
func init() { func init() {
commands = cmds() addCommands(cmds()...)
} }
func main() { func main() {
......
...@@ -224,3 +224,12 @@ func (c *Client) GetDeployment(name string) (*common.Deployment, error) { ...@@ -224,3 +224,12 @@ func (c *Client) GetDeployment(name string) (*common.Deployment, error) {
} }
return deployment, nil 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
}
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