mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-01 02:57:59 +00:00
Add RunCustom command to allow passing in a TokenHelper
This commit is contained in:
@@ -114,6 +114,11 @@ func (c *BaseCommand) Client() (*api.Client, error) {
|
|||||||
return client, nil
|
return client, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetTokenHelper sets the token helper on the command.
|
||||||
|
func (c *BaseCommand) SetTokenHelper(th token.TokenHelper) {
|
||||||
|
c.tokenHelper = th
|
||||||
|
}
|
||||||
|
|
||||||
// TokenHelper returns the token helper attached to the command.
|
// TokenHelper returns the token helper attached to the command.
|
||||||
func (c *BaseCommand) TokenHelper() (token.TokenHelper, error) {
|
func (c *BaseCommand) TokenHelper() (token.TokenHelper, error) {
|
||||||
if c.tokenHelper != nil {
|
if c.tokenHelper != nil {
|
||||||
|
|||||||
@@ -184,7 +184,7 @@ func (c *DeprecatedCommand) warn() {
|
|||||||
var Commands map[string]cli.CommandFactory
|
var Commands map[string]cli.CommandFactory
|
||||||
var DeprecatedCommands map[string]cli.CommandFactory
|
var DeprecatedCommands map[string]cli.CommandFactory
|
||||||
|
|
||||||
func initCommands(ui, serverCmdUi cli.Ui) {
|
func initCommands(ui, serverCmdUi cli.Ui, baseCmdTemplate *BaseCommand) {
|
||||||
loginHandlers := map[string]LoginHandler{
|
loginHandlers := map[string]LoginHandler{
|
||||||
"aws": &credAws.CLIHandler{},
|
"aws": &credAws.CLIHandler{},
|
||||||
"centrify": &credCentrify.CLIHandler{},
|
"centrify": &credCentrify.CLIHandler{},
|
||||||
@@ -205,42 +205,48 @@ func initCommands(ui, serverCmdUi cli.Ui) {
|
|||||||
"audit": func() (cli.Command, error) {
|
"audit": func() (cli.Command, error) {
|
||||||
return &AuditCommand{
|
return &AuditCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
"audit disable": func() (cli.Command, error) {
|
"audit disable": func() (cli.Command, error) {
|
||||||
return &AuditDisableCommand{
|
return &AuditDisableCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
"audit enable": func() (cli.Command, error) {
|
"audit enable": func() (cli.Command, error) {
|
||||||
return &AuditEnableCommand{
|
return &AuditEnableCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
"audit list": func() (cli.Command, error) {
|
"audit list": func() (cli.Command, error) {
|
||||||
return &AuditListCommand{
|
return &AuditListCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
"auth tune": func() (cli.Command, error) {
|
"auth tune": func() (cli.Command, error) {
|
||||||
return &AuthTuneCommand{
|
return &AuthTuneCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
"auth": func() (cli.Command, error) {
|
"auth": func() (cli.Command, error) {
|
||||||
return &AuthCommand{
|
return &AuthCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
Handlers: loginHandlers,
|
Handlers: loginHandlers,
|
||||||
}, nil
|
}, nil
|
||||||
@@ -248,21 +254,24 @@ func initCommands(ui, serverCmdUi cli.Ui) {
|
|||||||
"auth disable": func() (cli.Command, error) {
|
"auth disable": func() (cli.Command, error) {
|
||||||
return &AuthDisableCommand{
|
return &AuthDisableCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
"auth enable": func() (cli.Command, error) {
|
"auth enable": func() (cli.Command, error) {
|
||||||
return &AuthEnableCommand{
|
return &AuthEnableCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
"auth help": func() (cli.Command, error) {
|
"auth help": func() (cli.Command, error) {
|
||||||
return &AuthHelpCommand{
|
return &AuthHelpCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
Handlers: loginHandlers,
|
Handlers: loginHandlers,
|
||||||
}, nil
|
}, nil
|
||||||
@@ -270,49 +279,56 @@ func initCommands(ui, serverCmdUi cli.Ui) {
|
|||||||
"auth list": func() (cli.Command, error) {
|
"auth list": func() (cli.Command, error) {
|
||||||
return &AuthListCommand{
|
return &AuthListCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
"delete": func() (cli.Command, error) {
|
"delete": func() (cli.Command, error) {
|
||||||
return &DeleteCommand{
|
return &DeleteCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
"lease": func() (cli.Command, error) {
|
"lease": func() (cli.Command, error) {
|
||||||
return &LeaseCommand{
|
return &LeaseCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
"lease renew": func() (cli.Command, error) {
|
"lease renew": func() (cli.Command, error) {
|
||||||
return &LeaseRenewCommand{
|
return &LeaseRenewCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
"lease revoke": func() (cli.Command, error) {
|
"lease revoke": func() (cli.Command, error) {
|
||||||
return &LeaseRevokeCommand{
|
return &LeaseRevokeCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
"list": func() (cli.Command, error) {
|
"list": func() (cli.Command, error) {
|
||||||
return &ListCommand{
|
return &ListCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
"login": func() (cli.Command, error) {
|
"login": func() (cli.Command, error) {
|
||||||
return &LoginCommand{
|
return &LoginCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
Handlers: loginHandlers,
|
Handlers: loginHandlers,
|
||||||
}, nil
|
}, nil
|
||||||
@@ -320,168 +336,192 @@ func initCommands(ui, serverCmdUi cli.Ui) {
|
|||||||
"operator": func() (cli.Command, error) {
|
"operator": func() (cli.Command, error) {
|
||||||
return &OperatorCommand{
|
return &OperatorCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
"operator generate-root": func() (cli.Command, error) {
|
"operator generate-root": func() (cli.Command, error) {
|
||||||
return &OperatorGenerateRootCommand{
|
return &OperatorGenerateRootCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
"operator init": func() (cli.Command, error) {
|
"operator init": func() (cli.Command, error) {
|
||||||
return &OperatorInitCommand{
|
return &OperatorInitCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
"operator key-status": func() (cli.Command, error) {
|
"operator key-status": func() (cli.Command, error) {
|
||||||
return &OperatorKeyStatusCommand{
|
return &OperatorKeyStatusCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
"operator rekey": func() (cli.Command, error) {
|
"operator rekey": func() (cli.Command, error) {
|
||||||
return &OperatorRekeyCommand{
|
return &OperatorRekeyCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
"operator rotate": func() (cli.Command, error) {
|
"operator rotate": func() (cli.Command, error) {
|
||||||
return &OperatorRotateCommand{
|
return &OperatorRotateCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
"operator seal": func() (cli.Command, error) {
|
"operator seal": func() (cli.Command, error) {
|
||||||
return &OperatorSealCommand{
|
return &OperatorSealCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
"operator step-down": func() (cli.Command, error) {
|
"operator step-down": func() (cli.Command, error) {
|
||||||
return &OperatorStepDownCommand{
|
return &OperatorStepDownCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
"operator unseal": func() (cli.Command, error) {
|
"operator unseal": func() (cli.Command, error) {
|
||||||
return &OperatorUnsealCommand{
|
return &OperatorUnsealCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
"path-help": func() (cli.Command, error) {
|
"path-help": func() (cli.Command, error) {
|
||||||
return &PathHelpCommand{
|
return &PathHelpCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
"policy": func() (cli.Command, error) {
|
"policy": func() (cli.Command, error) {
|
||||||
return &PolicyCommand{
|
return &PolicyCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
"policy delete": func() (cli.Command, error) {
|
"policy delete": func() (cli.Command, error) {
|
||||||
return &PolicyDeleteCommand{
|
return &PolicyDeleteCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
"policy fmt": func() (cli.Command, error) {
|
"policy fmt": func() (cli.Command, error) {
|
||||||
return &PolicyFmtCommand{
|
return &PolicyFmtCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
"policy list": func() (cli.Command, error) {
|
"policy list": func() (cli.Command, error) {
|
||||||
return &PolicyListCommand{
|
return &PolicyListCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
"policy read": func() (cli.Command, error) {
|
"policy read": func() (cli.Command, error) {
|
||||||
return &PolicyReadCommand{
|
return &PolicyReadCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
"policy write": func() (cli.Command, error) {
|
"policy write": func() (cli.Command, error) {
|
||||||
return &PolicyWriteCommand{
|
return &PolicyWriteCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
"read": func() (cli.Command, error) {
|
"read": func() (cli.Command, error) {
|
||||||
return &ReadCommand{
|
return &ReadCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
"secrets": func() (cli.Command, error) {
|
"secrets": func() (cli.Command, error) {
|
||||||
return &SecretsCommand{
|
return &SecretsCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
"secrets disable": func() (cli.Command, error) {
|
"secrets disable": func() (cli.Command, error) {
|
||||||
return &SecretsDisableCommand{
|
return &SecretsDisableCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
"secrets enable": func() (cli.Command, error) {
|
"secrets enable": func() (cli.Command, error) {
|
||||||
return &SecretsEnableCommand{
|
return &SecretsEnableCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
"secrets list": func() (cli.Command, error) {
|
"secrets list": func() (cli.Command, error) {
|
||||||
return &SecretsListCommand{
|
return &SecretsListCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
"secrets move": func() (cli.Command, error) {
|
"secrets move": func() (cli.Command, error) {
|
||||||
return &SecretsMoveCommand{
|
return &SecretsMoveCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
"secrets tune": func() (cli.Command, error) {
|
"secrets tune": func() (cli.Command, error) {
|
||||||
return &SecretsTuneCommand{
|
return &SecretsTuneCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
"server": func() (cli.Command, error) {
|
"server": func() (cli.Command, error) {
|
||||||
return &ServerCommand{
|
return &ServerCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: serverCmdUi,
|
UI: serverCmdUi,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
AuditBackends: auditBackends,
|
AuditBackends: auditBackends,
|
||||||
CredentialBackends: credentialBackends,
|
CredentialBackends: credentialBackends,
|
||||||
@@ -494,63 +534,72 @@ func initCommands(ui, serverCmdUi cli.Ui) {
|
|||||||
"ssh": func() (cli.Command, error) {
|
"ssh": func() (cli.Command, error) {
|
||||||
return &SSHCommand{
|
return &SSHCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
"status": func() (cli.Command, error) {
|
"status": func() (cli.Command, error) {
|
||||||
return &StatusCommand{
|
return &StatusCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
"token": func() (cli.Command, error) {
|
"token": func() (cli.Command, error) {
|
||||||
return &TokenCommand{
|
return &TokenCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
"token create": func() (cli.Command, error) {
|
"token create": func() (cli.Command, error) {
|
||||||
return &TokenCreateCommand{
|
return &TokenCreateCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
"token capabilities": func() (cli.Command, error) {
|
"token capabilities": func() (cli.Command, error) {
|
||||||
return &TokenCapabilitiesCommand{
|
return &TokenCapabilitiesCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
"token lookup": func() (cli.Command, error) {
|
"token lookup": func() (cli.Command, error) {
|
||||||
return &TokenLookupCommand{
|
return &TokenLookupCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
"token renew": func() (cli.Command, error) {
|
"token renew": func() (cli.Command, error) {
|
||||||
return &TokenRenewCommand{
|
return &TokenRenewCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
"token revoke": func() (cli.Command, error) {
|
"token revoke": func() (cli.Command, error) {
|
||||||
return &TokenRevokeCommand{
|
return &TokenRevokeCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
"unwrap": func() (cli.Command, error) {
|
"unwrap": func() (cli.Command, error) {
|
||||||
return &UnwrapCommand{
|
return &UnwrapCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
@@ -558,14 +607,16 @@ func initCommands(ui, serverCmdUi cli.Ui) {
|
|||||||
return &VersionCommand{
|
return &VersionCommand{
|
||||||
VersionInfo: version.GetVersion(),
|
VersionInfo: version.GetVersion(),
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
"write": func() (cli.Command, error) {
|
"write": func() (cli.Command, error) {
|
||||||
return &WriteCommand{
|
return &WriteCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
@@ -579,10 +630,10 @@ func initCommands(ui, serverCmdUi cli.Ui) {
|
|||||||
return &DeprecatedCommand{
|
return &DeprecatedCommand{
|
||||||
Old: "audit-disable",
|
Old: "audit-disable",
|
||||||
New: "audit disable",
|
New: "audit disable",
|
||||||
UI: ui,
|
|
||||||
Command: &AuditDisableCommand{
|
Command: &AuditDisableCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
@@ -595,7 +646,8 @@ func initCommands(ui, serverCmdUi cli.Ui) {
|
|||||||
UI: ui,
|
UI: ui,
|
||||||
Command: &AuditEnableCommand{
|
Command: &AuditEnableCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
@@ -608,7 +660,8 @@ func initCommands(ui, serverCmdUi cli.Ui) {
|
|||||||
UI: ui,
|
UI: ui,
|
||||||
Command: &AuditListCommand{
|
Command: &AuditListCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
@@ -621,7 +674,8 @@ func initCommands(ui, serverCmdUi cli.Ui) {
|
|||||||
UI: ui,
|
UI: ui,
|
||||||
Command: &AuthDisableCommand{
|
Command: &AuthDisableCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
@@ -634,7 +688,8 @@ func initCommands(ui, serverCmdUi cli.Ui) {
|
|||||||
UI: ui,
|
UI: ui,
|
||||||
Command: &AuthEnableCommand{
|
Command: &AuthEnableCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
@@ -647,7 +702,8 @@ func initCommands(ui, serverCmdUi cli.Ui) {
|
|||||||
UI: ui,
|
UI: ui,
|
||||||
Command: &TokenCapabilitiesCommand{
|
Command: &TokenCapabilitiesCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
@@ -660,7 +716,8 @@ func initCommands(ui, serverCmdUi cli.Ui) {
|
|||||||
UI: ui,
|
UI: ui,
|
||||||
Command: &OperatorGenerateRootCommand{
|
Command: &OperatorGenerateRootCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
@@ -673,7 +730,8 @@ func initCommands(ui, serverCmdUi cli.Ui) {
|
|||||||
UI: ui,
|
UI: ui,
|
||||||
Command: &OperatorInitCommand{
|
Command: &OperatorInitCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
@@ -686,7 +744,8 @@ func initCommands(ui, serverCmdUi cli.Ui) {
|
|||||||
UI: ui,
|
UI: ui,
|
||||||
Command: &OperatorKeyStatusCommand{
|
Command: &OperatorKeyStatusCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
@@ -699,7 +758,8 @@ func initCommands(ui, serverCmdUi cli.Ui) {
|
|||||||
UI: ui,
|
UI: ui,
|
||||||
Command: &LeaseRenewCommand{
|
Command: &LeaseRenewCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
@@ -712,7 +772,8 @@ func initCommands(ui, serverCmdUi cli.Ui) {
|
|||||||
UI: ui,
|
UI: ui,
|
||||||
Command: &LeaseRevokeCommand{
|
Command: &LeaseRevokeCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
@@ -725,7 +786,8 @@ func initCommands(ui, serverCmdUi cli.Ui) {
|
|||||||
UI: ui,
|
UI: ui,
|
||||||
Command: &SecretsEnableCommand{
|
Command: &SecretsEnableCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
@@ -738,7 +800,8 @@ func initCommands(ui, serverCmdUi cli.Ui) {
|
|||||||
UI: ui,
|
UI: ui,
|
||||||
Command: &SecretsTuneCommand{
|
Command: &SecretsTuneCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
@@ -751,7 +814,8 @@ func initCommands(ui, serverCmdUi cli.Ui) {
|
|||||||
UI: ui,
|
UI: ui,
|
||||||
Command: &SecretsListCommand{
|
Command: &SecretsListCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
@@ -764,7 +828,8 @@ func initCommands(ui, serverCmdUi cli.Ui) {
|
|||||||
UI: ui,
|
UI: ui,
|
||||||
Command: &PoliciesDeprecatedCommand{
|
Command: &PoliciesDeprecatedCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
@@ -777,7 +842,8 @@ func initCommands(ui, serverCmdUi cli.Ui) {
|
|||||||
UI: ui,
|
UI: ui,
|
||||||
Command: &PolicyDeleteCommand{
|
Command: &PolicyDeleteCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
@@ -790,7 +856,8 @@ func initCommands(ui, serverCmdUi cli.Ui) {
|
|||||||
UI: ui,
|
UI: ui,
|
||||||
Command: &PolicyWriteCommand{
|
Command: &PolicyWriteCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
@@ -803,7 +870,8 @@ func initCommands(ui, serverCmdUi cli.Ui) {
|
|||||||
UI: ui,
|
UI: ui,
|
||||||
Command: &OperatorRekeyCommand{
|
Command: &OperatorRekeyCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
@@ -816,7 +884,8 @@ func initCommands(ui, serverCmdUi cli.Ui) {
|
|||||||
UI: ui,
|
UI: ui,
|
||||||
Command: &SecretsMoveCommand{
|
Command: &SecretsMoveCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
@@ -829,7 +898,8 @@ func initCommands(ui, serverCmdUi cli.Ui) {
|
|||||||
UI: ui,
|
UI: ui,
|
||||||
Command: &OperatorRotateCommand{
|
Command: &OperatorRotateCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
@@ -842,7 +912,8 @@ func initCommands(ui, serverCmdUi cli.Ui) {
|
|||||||
UI: ui,
|
UI: ui,
|
||||||
Command: &OperatorSealCommand{
|
Command: &OperatorSealCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
@@ -855,7 +926,8 @@ func initCommands(ui, serverCmdUi cli.Ui) {
|
|||||||
UI: ui,
|
UI: ui,
|
||||||
Command: &OperatorStepDownCommand{
|
Command: &OperatorStepDownCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
@@ -868,7 +940,8 @@ func initCommands(ui, serverCmdUi cli.Ui) {
|
|||||||
UI: ui,
|
UI: ui,
|
||||||
Command: &TokenCreateCommand{
|
Command: &TokenCreateCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
@@ -881,7 +954,8 @@ func initCommands(ui, serverCmdUi cli.Ui) {
|
|||||||
UI: ui,
|
UI: ui,
|
||||||
Command: &TokenLookupCommand{
|
Command: &TokenLookupCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
@@ -894,7 +968,8 @@ func initCommands(ui, serverCmdUi cli.Ui) {
|
|||||||
UI: ui,
|
UI: ui,
|
||||||
Command: &TokenRenewCommand{
|
Command: &TokenRenewCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
@@ -907,7 +982,8 @@ func initCommands(ui, serverCmdUi cli.Ui) {
|
|||||||
UI: ui,
|
UI: ui,
|
||||||
Command: &TokenRevokeCommand{
|
Command: &TokenRevokeCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
@@ -920,7 +996,8 @@ func initCommands(ui, serverCmdUi cli.Ui) {
|
|||||||
UI: ui,
|
UI: ui,
|
||||||
Command: &SecretsDisableCommand{
|
Command: &SecretsDisableCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
@@ -933,7 +1010,8 @@ func initCommands(ui, serverCmdUi cli.Ui) {
|
|||||||
UI: ui,
|
UI: ui,
|
||||||
Command: &OperatorUnsealCommand{
|
Command: &OperatorUnsealCommand{
|
||||||
BaseCommand: &BaseCommand{
|
BaseCommand: &BaseCommand{
|
||||||
UI: ui,
|
UI: ui,
|
||||||
|
tokenHelper: baseCmdTemplate.tokenHelper,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
|
|||||||
@@ -81,6 +81,16 @@ func setupEnv(args []string) []string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func Run(args []string) int {
|
func Run(args []string) int {
|
||||||
|
return RunCustom(args, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// RunCustom allows passing in a base command template to pass to other
|
||||||
|
// commands. Currenty, this is only used for setting a custom token helper.
|
||||||
|
func RunCustom(args []string, baseCmdTemplate *BaseCommand) int {
|
||||||
|
if baseCmdTemplate == nil {
|
||||||
|
baseCmdTemplate = &BaseCommand{}
|
||||||
|
}
|
||||||
|
|
||||||
args = setupEnv(args)
|
args = setupEnv(args)
|
||||||
|
|
||||||
// Don't use color if disabled
|
// Don't use color if disabled
|
||||||
@@ -129,7 +139,7 @@ func Run(args []string) int {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
initCommands(ui, serverCmdUi)
|
initCommands(ui, serverCmdUi, baseCmdTemplate)
|
||||||
|
|
||||||
// Calculate hidden commands from the deprecated ones
|
// Calculate hidden commands from the deprecated ones
|
||||||
hiddenCommands := make([]string, 0, len(DeprecatedCommands)+1)
|
hiddenCommands := make([]string, 0, len(DeprecatedCommands)+1)
|
||||||
|
|||||||
Reference in New Issue
Block a user