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
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
|
|
||||||
"github.com/codegangsta/cli"
|
"github.com/codegangsta/cli"
|
||||||
"github.com/deis/helm-dm/dm"
|
|
||||||
"github.com/deis/helm-dm/format"
|
"github.com/deis/helm-dm/format"
|
||||||
)
|
)
|
||||||
|
|
||||||
func listCmd() cli.Command {
|
func listCmd() cli.Command {
|
||||||
return cli.Command{
|
return cli.Command{
|
||||||
Name: "list",
|
Name: "list",
|
||||||
Usage: "Lists the deployments in the cluster",
|
Usage: "Lists the deployments in the cluster",
|
||||||
Action: func(c *cli.Context) {
|
Action: func(c *cli.Context) { run(c, list) },
|
||||||
if err := list(c.GlobalString("host")); err != nil {
|
|
||||||
format.Err("%s (Is the cluster running?)", err)
|
|
||||||
os.Exit(1)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func list(host string) error {
|
func list(c *cli.Context) error {
|
||||||
client := dm.NewClient(host).SetDebug(isDebugging)
|
list, err := client(c).ListDeployments()
|
||||||
list, err := client.ListDeployments()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
fmt.Println(list)
|
return format.YAML(list)
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in new issue