mirror of https://github.com/hashicorp/consul
command: add option for -wan to keys command
parent
67b179ccc9
commit
f771f2ef92
Binary file not shown.
|
@ -638,14 +638,11 @@ func (i *AgentRPC) handleListKeysLAN(client *rpcClient, seq uint64) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *AgentRPC) handleListKeysWAN(client *rpcClient, seq uint64) error {
|
func (i *AgentRPC) handleListKeysWAN(client *rpcClient, seq uint64) error {
|
||||||
|
resp, err := i.agent.ListKeysWAN()
|
||||||
|
|
||||||
header := responseHeader{
|
header := responseHeader{
|
||||||
Seq: seq,
|
Seq: seq,
|
||||||
Error: "",
|
Error: errToString(err),
|
||||||
}
|
|
||||||
|
|
||||||
resp, err := i.agent.ListKeysWAN()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return client.Send(&header, resp)
|
return client.Send(&header, resp)
|
||||||
|
|
|
@ -16,7 +16,7 @@ type KeysCommand struct {
|
||||||
|
|
||||||
func (c *KeysCommand) Run(args []string) int {
|
func (c *KeysCommand) Run(args []string) int {
|
||||||
var installKey, useKey, removeKey string
|
var installKey, useKey, removeKey string
|
||||||
var listKeys bool
|
var listKeys, wan bool
|
||||||
|
|
||||||
cmdFlags := flag.NewFlagSet("keys", flag.ContinueOnError)
|
cmdFlags := flag.NewFlagSet("keys", flag.ContinueOnError)
|
||||||
cmdFlags.Usage = func() { c.Ui.Output(c.Help()) }
|
cmdFlags.Usage = func() { c.Ui.Output(c.Help()) }
|
||||||
|
@ -25,6 +25,7 @@ func (c *KeysCommand) Run(args []string) int {
|
||||||
cmdFlags.StringVar(&useKey, "use", "", "use key")
|
cmdFlags.StringVar(&useKey, "use", "", "use key")
|
||||||
cmdFlags.StringVar(&removeKey, "remove", "", "remove key")
|
cmdFlags.StringVar(&removeKey, "remove", "", "remove key")
|
||||||
cmdFlags.BoolVar(&listKeys, "list", false, "list keys")
|
cmdFlags.BoolVar(&listKeys, "list", false, "list keys")
|
||||||
|
cmdFlags.BoolVar(&wan, "wan", false, "operate on wan keys")
|
||||||
|
|
||||||
rpcAddr := RPCAddrFlag(cmdFlags)
|
rpcAddr := RPCAddrFlag(cmdFlags)
|
||||||
if err := cmdFlags.Parse(args); err != nil {
|
if err := cmdFlags.Parse(args); err != nil {
|
||||||
|
@ -49,11 +50,20 @@ func (c *KeysCommand) Run(args []string) int {
|
||||||
}
|
}
|
||||||
|
|
||||||
if listKeys {
|
if listKeys {
|
||||||
keys, err := client.ListKeysLAN()
|
var keys map[string]int
|
||||||
|
var err error
|
||||||
|
|
||||||
|
if wan {
|
||||||
|
keys, err = client.ListKeysWAN()
|
||||||
|
} else {
|
||||||
|
keys, err = client.ListKeysLAN()
|
||||||
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Ui.Error(fmt.Sprintf("Error: %s", err))
|
c.Ui.Error(fmt.Sprintf("Error: %s", err))
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println(keys)
|
fmt.Println(keys)
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
@ -70,7 +80,8 @@ func (c *KeysCommand) Run(args []string) int {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0
|
c.Ui.Output(c.Help())
|
||||||
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *KeysCommand) Help() string {
|
func (c *KeysCommand) Help() string {
|
||||||
|
@ -94,6 +105,8 @@ Options:
|
||||||
operation may only be performed on keys which are
|
operation may only be performed on keys which are
|
||||||
not currently the primary key.
|
not currently the primary key.
|
||||||
-list List all keys currently in use within the cluster.
|
-list List all keys currently in use within the cluster.
|
||||||
|
-wan If talking with a server node, this flag can be used
|
||||||
|
to operate on the WAN gossip layer.
|
||||||
-rpc-addr=127.0.0.1:8400 RPC address of the Consul agent.
|
-rpc-addr=127.0.0.1:8400 RPC address of the Consul agent.
|
||||||
`
|
`
|
||||||
return strings.TrimSpace(helpText)
|
return strings.TrimSpace(helpText)
|
||||||
|
|
Loading…
Reference in New Issue