Commit ec4e9f30 authored by Adam Reese's avatar Adam Reese

Merge pull request #19 from adamreese/feat/delete

feat(delete): add delete verb
parents 08aed00f dbd90b5c
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)
}
...@@ -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