forked from vulcand/vulcand
/
endpoint.go
41 lines (37 loc) · 1.17 KB
/
endpoint.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package command
import (
"github.com/mailgun/vulcand/Godeps/_workspace/src/github.com/codegangsta/cli"
)
func NewEndpointCommand(cmd *Command) cli.Command {
return cli.Command{
Name: "endpoint",
Usage: "Operations with vulcan endpoint",
Subcommands: []cli.Command{
{
Name: "add",
Usage: "Add a new endpoint to location",
Action: cmd.addEndpointAction,
Flags: []cli.Flag{
cli.StringFlag{Name: "id", Usage: "endpoint id, autogenerated if empty"},
cli.StringFlag{Name: "upstream, up", Usage: "upstream id"},
cli.StringFlag{Name: "url", Usage: "url in form <scheme>://<host>:<port>"},
},
},
{
Name: "rm",
Usage: "Remove endpoint from location",
Flags: []cli.Flag{
cli.StringFlag{Name: "id", Usage: "endpoint id"},
cli.StringFlag{Name: "upstream, up", Usage: "upstream id"},
},
Action: cmd.deleteEndpointAction,
},
},
}
}
func (cmd *Command) addEndpointAction(c *cli.Context) {
cmd.printStatus(cmd.client.AddEndpoint(c.String("up"), c.String("id"), c.String("url")))
}
func (cmd *Command) deleteEndpointAction(c *cli.Context) {
cmd.printStatus(cmd.client.DeleteEndpoint(c.String("up"), c.String("id")))
}