Skip to content

Commit

Permalink
Add command to inspect vault snapshots (#23457)
Browse files Browse the repository at this point in the history
* add vault operator inspect command

* tidy

* add tests

* add changelog

* Update command/operator_raft_snapshot_inspect.go

Co-authored-by: Jason O'Donnell <[email protected]>

* Update command/operator_raft_snapshot_inspect.go

Co-authored-by: Jason O'Donnell <[email protected]>

* Update command/operator_raft_snapshot_inspect.go

Co-authored-by: Jason O'Donnell <[email protected]>

* Update command/operator_raft_snapshot_inspect.go

Co-authored-by: Jason O'Donnell <[email protected]>

* Update command/operator_raft_snapshot_inspect.go

Co-authored-by: Jason O'Donnell <[email protected]>

* remove test.snapshot file and create snapshot during test

* fix help text and add custom format flag

* Update changelog/23457.txt

Co-authored-by: Jason O'Donnell <[email protected]>

* add check that kvdepth is not less than zero

* remove kvprefix from flag names

* set details flag to default to true

* remove total size, we don't use it

* fix test that referenced old flag names

* add size calculations

* return all keys if depth set to 0

* Update command/operator_raft_snapshot_inspect.go

Co-authored-by: Jason O'Donnell <[email protected]>

* Update command/operator_raft_snapshot_inspect.go

Co-authored-by: Jason O'Donnell <[email protected]>

* Update command/operator_raft_snapshot_inspect.go

* revert go.mod

* update comment on temp file

* update comment on closing writer

* remove temporary file, and process state.bin in memory

* return metadata like info

* remove unnused function

* remove ReadSnapshot func, and unnecessary goroutine

* remove handler, and zero values

* move defer, and return error instead of logging

* add subcommand doc

* remove -format flag

* remove comments

* change copy to copyN

* remove formatters

* remove formatters

* remove duplicate check

* fix error checks

* remove unused consts

---------

Co-authored-by: Jason O'Donnell <[email protected]>
  • Loading branch information
elliesterner and jasonodonnell authored Oct 31, 2023
1 parent 30a8435 commit 63ab253
Show file tree
Hide file tree
Showing 7 changed files with 735 additions and 6 deletions.
3 changes: 3 additions & 0 deletions changelog/23457.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:feature
cli/snapshot: Add CLI tool to inspect Vault snapshots
```
5 changes: 5 additions & 0 deletions command/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,11 @@ func initCommands(ui, serverCmdUi cli.Ui, runOpts *RunOptions) map[string]cli.Co
BaseCommand: getBaseCommand(),
}, nil
},
"operator raft snapshot inspect": func() (cli.Command, error) {
return &OperatorRaftSnapshotInspectCommand{
BaseCommand: getBaseCommand(),
}, nil
},
"operator raft snapshot restore": func() (cli.Command, error) {
return &OperatorRaftSnapshotRestoreCommand{
BaseCommand: getBaseCommand(),
Expand Down
4 changes: 4 additions & 0 deletions command/operator_raft_snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ Usage: vault operator raft snapshot <subcommand> [options] [args]
$ vault operator raft snapshot save raft.snap
Inspects a snapshot based on a file:
$ vault operator raft snapshot inspect raft.snap
Please see the individual subcommand help for detailed usage information.
`

Expand Down
Loading

0 comments on commit 63ab253

Please sign in to comment.