From c2620e136d389414c50f9abee6e32efe692ff00f Mon Sep 17 00:00:00 2001 From: Alexander Scheel Date: Wed, 21 Dec 2022 10:01:57 -0500 Subject: [PATCH] Add PKI base command (#18512) Signed-off-by: Alexander Scheel Signed-off-by: Alexander Scheel --- command/commands.go | 15 ++++++++++----- command/pki.go | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 5 deletions(-) create mode 100644 command/pki.go diff --git a/command/commands.go b/command/commands.go index 35465ef811..9327ae72c3 100644 --- a/command/commands.go +++ b/command/commands.go @@ -526,6 +526,16 @@ func initCommands(ui, serverCmdUi cli.Ui, runOpts *RunOptions) { BaseCommand: getBaseCommand(), }, nil }, + "pki": func() (cli.Command, error) { + return &PKICommand{ + BaseCommand: getBaseCommand(), + }, nil + }, + "pki health-check": func() (cli.Command, error) { + return &PKIHealthCheckCommand{ + BaseCommand: getBaseCommand(), + }, nil + }, "plugin": func() (cli.Command, error) { return &PluginCommand{ BaseCommand: getBaseCommand(), @@ -797,11 +807,6 @@ func initCommands(ui, serverCmdUi cli.Ui, runOpts *RunOptions) { ShutdownCh: MakeShutdownCh(), }, nil }, - "pki health-check": func() (cli.Command, error) { - return &PKIHealthCheckCommand{ - BaseCommand: getBaseCommand(), - }, nil - }, } initCommandsEnt(ui, serverCmdUi, runOpts) diff --git a/command/pki.go b/command/pki.go new file mode 100644 index 0000000000..4212ee6f86 --- /dev/null +++ b/command/pki.go @@ -0,0 +1,39 @@ +package command + +import ( + "strings" + + "github.com/mitchellh/cli" +) + +var _ cli.Command = (*PKICommand)(nil) + +type PKICommand struct { + *BaseCommand +} + +func (c *PKICommand) Synopsis() string { + return "Interact with Vault's Key-Value storage" +} + +func (c *PKICommand) Help() string { + helpText := ` +Usage: vault pki [options] [args] + + This command has subcommands for interacting with Vault's PKI Secrets + Engine. Here are some simple examples, and more detailed examples are + available in the subcommands or the documentation. + + Check the health of a PKI mount, to the best of this token's abilities: + + $ vault pki health-check pki + + Please see the individual subcommand help for detailed usage information. +` + + return strings.TrimSpace(helpText) +} + +func (c *PKICommand) Run(args []string) int { + return cli.RunResultHelp +}