forked from hashicorp/vault
-
Notifications
You must be signed in to change notification settings - Fork 0
/
key_status.go
54 lines (43 loc) · 1.17 KB
/
key_status.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package command
import (
"fmt"
"strings"
)
// KeyStatusCommand is a Command that provides information about the key status
type KeyStatusCommand struct {
Meta
}
func (c *KeyStatusCommand) Run(args []string) int {
flags := c.Meta.FlagSet("key-status", FlagSetDefault)
flags.Usage = func() { c.Ui.Error(c.Help()) }
if err := flags.Parse(args); err != nil {
return 1
}
client, err := c.Client()
if err != nil {
c.Ui.Error(fmt.Sprintf(
"Error initializing client: %s", err))
return 2
}
status, err := client.Sys().KeyStatus()
if err != nil {
c.Ui.Error(fmt.Sprintf(
"Error reading audits: %s", err))
return 2
}
c.Ui.Output(fmt.Sprintf("Key Term: %d", status.Term))
c.Ui.Output(fmt.Sprintf("Installation Time: %v", status.InstallTime))
return 0
}
func (c *KeyStatusCommand) Synopsis() string {
return "Provides information about the active encryption key"
}
func (c *KeyStatusCommand) Help() string {
helpText := `
Usage: vault key-status [options]
Provides information about the active encryption key. Specifically,
the current key term and the key installation time.
General Options:
` + generalOptionsUsage()
return strings.TrimSpace(helpText)
}