2015-05-28 01:17:02 +00:00
|
|
|
package command
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"strings"
|
2016-04-01 17:16:05 +00:00
|
|
|
|
|
|
|
"github.com/hashicorp/vault/meta"
|
2015-05-28 01:17:02 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// KeyStatusCommand is a Command that provides information about the key status
|
|
|
|
type KeyStatusCommand struct {
|
2016-04-01 17:16:05 +00:00
|
|
|
meta.Meta
|
2015-05-28 01:17:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c *KeyStatusCommand) Run(args []string) int {
|
2016-04-01 17:16:05 +00:00
|
|
|
flags := c.Meta.FlagSet("key-status", meta.FlagSetDefault)
|
2015-05-28 01:17:02 +00:00
|
|
|
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:
|
2016-04-01 20:50:12 +00:00
|
|
|
` + meta.GeneralOptionsUsage()
|
2015-05-28 01:17:02 +00:00
|
|
|
return strings.TrimSpace(helpText)
|
|
|
|
}
|