Commit f76a17ac authored by Adam Reese's avatar Adam Reese

feat(list): add list command

parent db9ab4aa
......@@ -17,6 +17,16 @@ func main() {
app.Usage = `Deploy and manage packages.`
app.Commands = commands()
// TODO: make better
app.Flags = []cli.Flag{
cli.StringFlag{
Name: "host,u",
Usage: "The URL of the DM server.",
EnvVar: "HELM_HOST",
Value: "https://localhost:8181/FIXME_NOT_RIGHT",
},
}
app.Run(os.Args)
}
......@@ -89,7 +99,7 @@ func commands() []cli.Command {
d.Input = os.Stdin
}
if err := deploy(d, c.String("host"), c.Bool("dry-run")); err != nil {
if err := deploy(d, c.GlobalString("host"), c.Bool("dry-run")); err != nil {
format.Error("%s (Try running 'helm doctor')", err)
os.Exit(1)
}
......@@ -119,16 +129,11 @@ func commands() []cli.Command {
Usage: "The default repository",
Value: "kubernetes/application-dm-templates",
},
cli.StringFlag{
Name: "host,u",
Usage: "The URL of the DM server.",
EnvVar: "HELM_HOST",
Value: "https://localhost:8181/FIXME_NOT_RIGHT",
},
},
},
{
Name: "search",
},
listCmd(),
}
}
package main
import (
"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.Error("%s (Is the cluster running?)", err)
os.Exit(1)
}
},
}
}
func list(host string) error {
client := dm.NewClient(host)
client.Protocol = "http"
return client.ListDeployments()
}
......@@ -96,3 +96,13 @@ func (c *Client) callHttp(path, method, action string, reader io.ReadCloser) (st
return string(body), nil
}
func (c *Client) ListDeployments() error {
var d interface{}
if err := c.CallService("deployments", "GET", "foo", &d, nil); err != nil {
return err
}
fmt.Printf("%#v\n", d)
return 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