From f771f2ef92cbcc62250cd68b43a5f2bcc53ede0e Mon Sep 17 00:00:00 2001 From: Ryan Uber Date: Mon, 8 Sep 2014 19:38:30 -0700 Subject: [PATCH] command: add option for -wan to keys command --- command/.keys.go.swp | Bin 0 -> 12288 bytes command/agent/rpc.go | 9 +++------ command/keys.go | 19 ++++++++++++++++--- 3 files changed, 19 insertions(+), 9 deletions(-) create mode 100644 command/.keys.go.swp diff --git a/command/.keys.go.swp b/command/.keys.go.swp new file mode 100644 index 0000000000000000000000000000000000000000..370906d22e6ad9df77d1abb6dd771a7f967c2a1b GIT binary patch literal 12288 zcmeHNO^g&p6fRKEQIWqGPwJzM>kOHlS-^-{T@u{*L-<)_S&bnmHQhBc9lE>P>h4`f zL@#>Oc+o^jJfYDQ-+bvHY+?5^QR(nG$T{;Busy|2D{ zRTHW+@#MaPw7a!S;Im1HLHE|9FRa}n*4`n68OSK>D8sK-`;_g*!%jTDvlVDp2Fta7 zschKp>2_k=cF#}yS*PXdu-%tQ-*>f%+pdn1EWlS7%E)VdG~3|tKZ z8^o@iJ0{rTZf6^9-7 zzx@6G*G3`!1bziB0vCYqf$xA%fRBNXfMz4qODz1D^rsfDeFIfB`TEJOLaA_5hoKb-)@x0Ke6Q_!+ne{0Mvld<}dBdZxG@=;4E+kcn3HDtOGt@ z4<3Lq;Nm(V-T>x+^}y%XW88oTfct?hz$RcL@C(NE3xLP>9FKAJx#k%-Eow%knTg0b zC?nZZ3H5Z6_%Q`?pbV+VHG??ybwqr6#u42ta;fgp_Wih>&JWf!Xm$|kIPsHugOb$v zQIAduvFJO0mb8u|r@RdObO251dEY}};8wEZ+lL6h5R1*m z=v3MwQRsGj0TxYkW<@lbT$3lX4V_=&F7hZ>7U_VM#{>6NA1cDRy^bF#FQ01grfnKB zDBi0`b})v;Oe{|MSwR<*5d%W%c^Se9Nu)HdhUkL7vgD0&SPUklSk{U~K|Pii#~}kq zTFkNBCJ`?mH_UTBmdBbL7qzn1(c~1JSfPMEj(WI4@!TP5ZfnkO&17kurFFNJw`~Yf zLxnBN_k^hV-GaycQ2e$javZM0S2luF|EEPEz13RPx?$Qnj8dNlQJn{p%zW&12182C11x%~i)FDGoasO(ig_NACyT+V_>mQ~z>_CZn4?^d^vEJV zDwCxuspY-q0zur^F-%*L)VE_-u@`%XB{Kz~6h6?}4ZTOPf+wxR(jaK0lr$b3m0_)L z!=%7Ddt{S(Y0B=)>(;|s2Tw{%NGLOPk6iLAhQOn72163K*j zFgW@1;jqiBFEdwcVOOZsM>0FZ6DlWF1B-Xc6#?aTWi_M1JVUd@ZCH7!D`C%L=o{IS*oc3i(*t>WER_*69 zWd`ujM3{Ed!`DJUch1n6`Or^YtW!b1jrbj~=j0UwJN}x3%5A?uv?I`$HYwHdn^d|d MvF`CQ&ByD-f6l=}_5c6? literal 0 HcmV?d00001 diff --git a/command/agent/rpc.go b/command/agent/rpc.go index e5934fc8ad..09bf68fb87 100644 --- a/command/agent/rpc.go +++ b/command/agent/rpc.go @@ -638,14 +638,11 @@ func (i *AgentRPC) handleListKeysLAN(client *rpcClient, seq uint64) error { } func (i *AgentRPC) handleListKeysWAN(client *rpcClient, seq uint64) error { + resp, err := i.agent.ListKeysWAN() + header := responseHeader{ Seq: seq, - Error: "", - } - - resp, err := i.agent.ListKeysWAN() - if err != nil { - return err + Error: errToString(err), } return client.Send(&header, resp) diff --git a/command/keys.go b/command/keys.go index 4f063a2dd1..49bac18315 100644 --- a/command/keys.go +++ b/command/keys.go @@ -16,7 +16,7 @@ type KeysCommand struct { func (c *KeysCommand) Run(args []string) int { var installKey, useKey, removeKey string - var listKeys bool + var listKeys, wan bool cmdFlags := flag.NewFlagSet("keys", flag.ContinueOnError) 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(&removeKey, "remove", "", "remove key") cmdFlags.BoolVar(&listKeys, "list", false, "list keys") + cmdFlags.BoolVar(&wan, "wan", false, "operate on wan keys") rpcAddr := RPCAddrFlag(cmdFlags) if err := cmdFlags.Parse(args); err != nil { @@ -49,11 +50,20 @@ func (c *KeysCommand) Run(args []string) int { } 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 { c.Ui.Error(fmt.Sprintf("Error: %s", err)) return 1 } + fmt.Println(keys) return 0 } @@ -70,7 +80,8 @@ func (c *KeysCommand) Run(args []string) int { return 0 } - return 0 + c.Ui.Output(c.Help()) + return 1 } func (c *KeysCommand) Help() string { @@ -94,6 +105,8 @@ Options: operation may only be performed on keys which are not currently the primary key. -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. ` return strings.TrimSpace(helpText)