diff --git a/command/commands.go b/command/commands.go index e5cccce585..b12cc91f41 100644 --- a/command/commands.go +++ b/command/commands.go @@ -327,6 +327,11 @@ func initCommands(ui, serverCmdUi cli.Ui, runOpts *RunOptions) { ShutdownCh: MakeShutdownCh(), }, nil }, + "operator raft": func() (cli.Command, error) { + return &OperatorRaftCommand{ + BaseCommand: getBaseCommand(), + }, nil + }, "operator raft configuration": func() (cli.Command, error) { return &OperatorRaftConfigurationCommand{ BaseCommand: getBaseCommand(), @@ -342,6 +347,11 @@ func initCommands(ui, serverCmdUi cli.Ui, runOpts *RunOptions) { BaseCommand: getBaseCommand(), }, nil }, + "operator raft snapshot": func() (cli.Command, error) { + return &OperatorRaftSnapshotCommand{ + BaseCommand: getBaseCommand(), + }, nil + }, "operator raft snapshot restore": func() (cli.Command, error) { return &OperatorRaftSnapshotRestoreCommand{ BaseCommand: getBaseCommand(), diff --git a/command/operator_raft.go b/command/operator_raft.go new file mode 100644 index 0000000000..5af096fb52 --- /dev/null +++ b/command/operator_raft.go @@ -0,0 +1,47 @@ +package command + +import ( + "strings" + + "github.com/mitchellh/cli" +) + +var _ cli.Command = (*OperatorRaftCommand)(nil) + +type OperatorRaftCommand struct { + *BaseCommand +} + +func (c *OperatorRaftCommand) Synopsis() string { + return "Interact with Vault's raft storage backend" +} + +func (c *OperatorRaftCommand) Help() string { + helpText := ` +Usage: vault operator raft [options] [args] + + This command groups subcommands for operators interacting with the Vault raft storage backend. Most + users will not need to interact with these commands. Here are a few examples + of the raft operator commands: + + Joins a node to the raft cluster: + + $ vault operator raft join https://127.0.0.1:8200 + + Returns the raft cluster configuration: + + $ vault operator raft configuration + + Removes a node from the raft cluster: + + $ vault operator raft remove-peer + + Please see the individual subcommand help for detailed usage information. +` + + return strings.TrimSpace(helpText) +} + +func (c *OperatorRaftCommand) Run(args []string) int { + return cli.RunResultHelp +} diff --git a/command/operator_raft_snapshot.go b/command/operator_raft_snapshot.go new file mode 100644 index 0000000000..8003d295e7 --- /dev/null +++ b/command/operator_raft_snapshot.go @@ -0,0 +1,42 @@ +package command + +import ( + "strings" + + "github.com/mitchellh/cli" +) + +var _ cli.Command = (*OperatorRaftSnapshotCommand)(nil) + +type OperatorRaftSnapshotCommand struct { + *BaseCommand +} + +func (c *OperatorRaftSnapshotCommand) Synopsis() string { + return "Restores and saves snapshots from the raft cluster" +} + +func (c *OperatorRaftSnapshotCommand) Help() string { + helpText := ` +Usage: vault operator raft snapshot [options] [args] + + This command groups subcommands for operators interacting with the snapshot functionality of + the raft storage backend. Here are a few examples of the raft snapshot operator commands: + + Installs the provided snapshot, returning the cluster to the state defined in it: + + $ vault operator raft snapshot restore raft.snap + + Saves a snapshot of the current state of the raft cluster into a file: + + $ vault operator raft snapshot save raft.snap + + Please see the individual subcommand help for detailed usage information. +` + + return strings.TrimSpace(helpText) +} + +func (c *OperatorRaftSnapshotCommand) Run(args []string) int { + return cli.RunResultHelp +} diff --git a/command/operator_raft_snapshot_restore.go b/command/operator_raft_snapshot_restore.go index c3f9cf19e2..bf5c6eb5b1 100644 --- a/command/operator_raft_snapshot_restore.go +++ b/command/operator_raft_snapshot_restore.go @@ -18,7 +18,7 @@ type OperatorRaftSnapshotRestoreCommand struct { } func (c *OperatorRaftSnapshotRestoreCommand) Synopsis() string { - return "Installs the provided snapshot, returning the cluster to the state defined in it." + return "Installs the provided snapshot, returning the cluster to the state defined in it" } func (c *OperatorRaftSnapshotRestoreCommand) Help() string { diff --git a/command/operator_raft_snapshot_save.go b/command/operator_raft_snapshot_save.go index b9eadec02b..adaa1e87b2 100644 --- a/command/operator_raft_snapshot_save.go +++ b/command/operator_raft_snapshot_save.go @@ -17,7 +17,7 @@ type OperatorRaftSnapshotSaveCommand struct { } func (c *OperatorRaftSnapshotSaveCommand) Synopsis() string { - return "Saves a snapshot of the current state of the raft cluster into a file." + return "Saves a snapshot of the current state of the raft cluster into a file" } func (c *OperatorRaftSnapshotSaveCommand) Help() string {