mirror of https://github.com/helm/helm
Merge pull request #9 from adamreese/get-deployments
feat(get): add get deployment commandpull/291/head
commit
20d3ea9fb6
@ -0,0 +1,29 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/codegangsta/cli"
|
||||
"github.com/deis/helm-dm/format"
|
||||
)
|
||||
|
||||
func getCmd() cli.Command {
|
||||
return cli.Command{
|
||||
Name: "get",
|
||||
Usage: "Retrieves the supplied deployment",
|
||||
Action: func(c *cli.Context) { run(c, get) },
|
||||
}
|
||||
}
|
||||
|
||||
func get(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).GetDeployment(name)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return format.YAML(deployment)
|
||||
}
|
@ -1,33 +1,22 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/codegangsta/cli"
|
||||
"github.com/deis/helm-dm/dm"
|
||||
"github.com/deis/helm-dm/format"
|
||||
)
|
||||
|
||||
func listCmd() cli.Command {
|
||||
return cli.Command{
|
||||
Name: "list",
|
||||
Usage: "Lists the deployments in the cluster",
|
||||
Action: func(c *cli.Context) {
|
||||
if err := list(c.GlobalString("host")); err != nil {
|
||||
format.Err("%s (Is the cluster running?)", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
},
|
||||
Name: "list",
|
||||
Usage: "Lists the deployments in the cluster",
|
||||
Action: func(c *cli.Context) { run(c, list) },
|
||||
}
|
||||
}
|
||||
|
||||
func list(host string) error {
|
||||
client := dm.NewClient(host).SetDebug(isDebugging)
|
||||
list, err := client.ListDeployments()
|
||||
func list(c *cli.Context) error {
|
||||
list, err := client(c).ListDeployments()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Println(list)
|
||||
return nil
|
||||
return format.YAML(list)
|
||||
}
|
||||
|
Loading…
Reference in new issue