Add CLI support for restore endpoint.

+ Add the relevant parts to the command line tool and the client
  package.
+ Small improvements to cryptor's restore function:
  + Don't try to restore if the store is already active.
  + Flush the persistence key cache once the restoration occurs.
+ The redoctober program now explicitly mentions that a config file is
  invalid when that's the case.
This commit is contained in:
Kyle Isom
2016-08-16 15:12:14 -07:00
parent 4d7d8257e7
commit 4da501264a
4 changed files with 50 additions and 0 deletions
+24
View File
@@ -45,6 +45,7 @@ var commandSet = map[string]command{
"order": command{Run: runOrder, Desc: "place an order for delegations"},
"owners": command{Run: runOwner, Desc: "show owners list"},
"status": command{Run: runStatus, Desc: "show Red October persistent delegation state"},
"restore": command{Run: runRestore, Desc: "perform a restore delegation"},
}
func registerFlags() {
@@ -132,6 +133,29 @@ func runDelegate() {
fmt.Println(resp.Status)
}
func runRestore() {
req := core.DelegateRequest{
Name: user,
Password: pswd,
Uses: uses,
Time: duration,
}
resp, err := roServer.Restore(req)
processError(err)
if resp.Status != "ok" {
fmt.Fprintf(os.Stderr, "failed: %s\n", resp.Status)
os.Exit(1)
}
var st core.StatusData
err = json.Unmarshal(resp.Response, &st)
processError(err)
fmt.Println("Restore delegation complete; persistence is now", st.Status)
}
// TODO: summary response needs better formatting
func runSummary() {
req := core.SummaryRequest{