mirror of https://github.com/hashicorp/consul
command: basic rpc works for keys command
parent
4dd1b42477
commit
67b179ccc9
|
@ -741,17 +741,20 @@ func loadKeyringFile(keyringFile string) *memberlist.Keyring {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListKeysLAN returns the keys installed on the LAN gossip pool
|
// ListKeysLAN returns the keys installed on the LAN gossip pool
|
||||||
func (a *Agent) ListKeysLAN() map[string]int {
|
func (a *Agent) ListKeysLAN() (*serf.KeyResponse, error) {
|
||||||
if a.server != nil {
|
if a.server != nil {
|
||||||
return a.server.ListKeysLAN()
|
km := a.server.KeyManagerLAN()
|
||||||
|
return km.ListKeys()
|
||||||
}
|
}
|
||||||
return a.client.ListKeysLAN()
|
km := a.client.KeyManagerLAN()
|
||||||
|
return km.ListKeys()
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListKeysWAN returns the keys installed on the WAN gossip pool
|
// ListKeysWAN returns the keys installed on the WAN gossip pool
|
||||||
func (a *Agent) ListKeysWAN() map[string]int {
|
func (a *Agent) ListKeysWAN() (*serf.KeyResponse, error) {
|
||||||
if a.server != nil {
|
if a.server != nil {
|
||||||
return a.server.ListKeysWAN()
|
km := a.server.KeyManagerWAN()
|
||||||
|
return km.ListKeys()
|
||||||
}
|
}
|
||||||
return nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -629,7 +629,11 @@ func (i *AgentRPC) handleListKeysLAN(client *rpcClient, seq uint64) error {
|
||||||
Seq: seq,
|
Seq: seq,
|
||||||
Error: "",
|
Error: "",
|
||||||
}
|
}
|
||||||
resp := i.agent.ListKeysLAN()
|
resp, err := i.agent.ListKeysLAN()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
return client.Send(&header, resp)
|
return client.Send(&header, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -638,7 +642,12 @@ func (i *AgentRPC) handleListKeysWAN(client *rpcClient, seq uint64) error {
|
||||||
Seq: seq,
|
Seq: seq,
|
||||||
Error: "",
|
Error: "",
|
||||||
}
|
}
|
||||||
resp := i.agent.ListKeysWAN()
|
|
||||||
|
resp, err := i.agent.ListKeysWAN()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
return client.Send(&header, resp)
|
return client.Send(&header, resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -176,6 +176,28 @@ func (c *RPCClient) WANMembers() ([]Member, error) {
|
||||||
return resp.Members, err
|
return resp.Members, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *RPCClient) ListKeysLAN() (map[string]int, error) {
|
||||||
|
header := requestHeader{
|
||||||
|
Command: listKeysLANCommand,
|
||||||
|
Seq: c.getSeq(),
|
||||||
|
}
|
||||||
|
resp := make(map[string]int)
|
||||||
|
|
||||||
|
err := c.genericRPC(&header, nil, &resp)
|
||||||
|
return resp, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *RPCClient) ListKeysWAN() (map[string]int, error) {
|
||||||
|
header := requestHeader{
|
||||||
|
Command: listKeysWANCommand,
|
||||||
|
Seq: c.getSeq(),
|
||||||
|
}
|
||||||
|
resp := make(map[string]int)
|
||||||
|
|
||||||
|
err := c.genericRPC(&header, nil, &resp)
|
||||||
|
return resp, err
|
||||||
|
}
|
||||||
|
|
||||||
// Leave is used to trigger a graceful leave and shutdown
|
// Leave is used to trigger a graceful leave and shutdown
|
||||||
func (c *RPCClient) Leave() error {
|
func (c *RPCClient) Leave() error {
|
||||||
header := requestHeader{
|
header := requestHeader{
|
||||||
|
|
|
@ -49,8 +49,12 @@ func (c *KeysCommand) Run(args []string) int {
|
||||||
}
|
}
|
||||||
|
|
||||||
if listKeys {
|
if listKeys {
|
||||||
km := client.KeyManager()
|
keys, err := client.ListKeysLAN()
|
||||||
fmt.Println(km.ListKeys())
|
if err != nil {
|
||||||
|
c.Ui.Error(fmt.Sprintf("Error: %s", err))
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
fmt.Println(keys)
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -206,8 +206,8 @@ func (c *Client) UserEvent(name string, payload []byte) error {
|
||||||
return c.serf.UserEvent(userEventName(name), payload, false)
|
return c.serf.UserEvent(userEventName(name), payload, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
// KeyManager returns the Serf keyring manager
|
// KeyManager returns the LAN Serf keyring manager
|
||||||
func (c *Client) KeyManager() *serf.KeyManager {
|
func (c *Client) KeyManagerLAN() *serf.KeyManager {
|
||||||
return c.serf.KeyManager()
|
return c.serf.KeyManager()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue