From 586c03e5529f7dd3ee9fe45693a42071cc1c4a5f Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Wed, 23 May 2018 12:34:48 -0400 Subject: [PATCH] Fix panic on deprecated audit-disable and some cleanup (#4619) --- command/commands.go | 169 ++++++++------------------------------------ 1 file changed, 29 insertions(+), 140 deletions(-) diff --git a/command/commands.go b/command/commands.go index 4bf2ba7e73..76831b38c0 100644 --- a/command/commands.go +++ b/command/commands.go @@ -564,12 +564,9 @@ func initCommands(ui, serverCmdUi cli.Ui, runOpts *RunOptions) { return &DeprecatedCommand{ Old: "audit-disable", New: "audit disable", + UI: ui, Command: &AuditDisableCommand{ - BaseCommand: &BaseCommand{ - UI: ui, - tokenHelper: runOpts.TokenHelper, - flagAddress: runOpts.Address, - }, + BaseCommand: getBaseCommand(), }, }, nil }, @@ -580,11 +577,7 @@ func initCommands(ui, serverCmdUi cli.Ui, runOpts *RunOptions) { New: "audit enable", UI: ui, Command: &AuditEnableCommand{ - BaseCommand: &BaseCommand{ - UI: ui, - tokenHelper: runOpts.TokenHelper, - flagAddress: runOpts.Address, - }, + BaseCommand: getBaseCommand(), }, }, nil }, @@ -595,11 +588,7 @@ func initCommands(ui, serverCmdUi cli.Ui, runOpts *RunOptions) { New: "audit list", UI: ui, Command: &AuditListCommand{ - BaseCommand: &BaseCommand{ - UI: ui, - tokenHelper: runOpts.TokenHelper, - flagAddress: runOpts.Address, - }, + BaseCommand: getBaseCommand(), }, }, nil }, @@ -610,11 +599,7 @@ func initCommands(ui, serverCmdUi cli.Ui, runOpts *RunOptions) { New: "auth disable", UI: ui, Command: &AuthDisableCommand{ - BaseCommand: &BaseCommand{ - UI: ui, - tokenHelper: runOpts.TokenHelper, - flagAddress: runOpts.Address, - }, + BaseCommand: getBaseCommand(), }, }, nil }, @@ -625,11 +610,7 @@ func initCommands(ui, serverCmdUi cli.Ui, runOpts *RunOptions) { New: "auth enable", UI: ui, Command: &AuthEnableCommand{ - BaseCommand: &BaseCommand{ - UI: ui, - tokenHelper: runOpts.TokenHelper, - flagAddress: runOpts.Address, - }, + BaseCommand: getBaseCommand(), }, }, nil }, @@ -640,11 +621,7 @@ func initCommands(ui, serverCmdUi cli.Ui, runOpts *RunOptions) { New: "token capabilities", UI: ui, Command: &TokenCapabilitiesCommand{ - BaseCommand: &BaseCommand{ - UI: ui, - tokenHelper: runOpts.TokenHelper, - flagAddress: runOpts.Address, - }, + BaseCommand: getBaseCommand(), }, }, nil }, @@ -655,11 +632,7 @@ func initCommands(ui, serverCmdUi cli.Ui, runOpts *RunOptions) { New: "operator generate-root", UI: ui, Command: &OperatorGenerateRootCommand{ - BaseCommand: &BaseCommand{ - UI: ui, - tokenHelper: runOpts.TokenHelper, - flagAddress: runOpts.Address, - }, + BaseCommand: getBaseCommand(), }, }, nil }, @@ -670,11 +643,7 @@ func initCommands(ui, serverCmdUi cli.Ui, runOpts *RunOptions) { New: "operator init", UI: ui, Command: &OperatorInitCommand{ - BaseCommand: &BaseCommand{ - UI: ui, - tokenHelper: runOpts.TokenHelper, - flagAddress: runOpts.Address, - }, + BaseCommand: getBaseCommand(), }, }, nil }, @@ -685,11 +654,7 @@ func initCommands(ui, serverCmdUi cli.Ui, runOpts *RunOptions) { New: "operator key-status", UI: ui, Command: &OperatorKeyStatusCommand{ - BaseCommand: &BaseCommand{ - UI: ui, - tokenHelper: runOpts.TokenHelper, - flagAddress: runOpts.Address, - }, + BaseCommand: getBaseCommand(), }, }, nil }, @@ -700,11 +665,7 @@ func initCommands(ui, serverCmdUi cli.Ui, runOpts *RunOptions) { New: "lease renew", UI: ui, Command: &LeaseRenewCommand{ - BaseCommand: &BaseCommand{ - UI: ui, - tokenHelper: runOpts.TokenHelper, - flagAddress: runOpts.Address, - }, + BaseCommand: getBaseCommand(), }, }, nil }, @@ -715,11 +676,7 @@ func initCommands(ui, serverCmdUi cli.Ui, runOpts *RunOptions) { New: "lease revoke", UI: ui, Command: &LeaseRevokeCommand{ - BaseCommand: &BaseCommand{ - UI: ui, - tokenHelper: runOpts.TokenHelper, - flagAddress: runOpts.Address, - }, + BaseCommand: getBaseCommand(), }, }, nil }, @@ -730,11 +687,7 @@ func initCommands(ui, serverCmdUi cli.Ui, runOpts *RunOptions) { New: "secrets enable", UI: ui, Command: &SecretsEnableCommand{ - BaseCommand: &BaseCommand{ - UI: ui, - tokenHelper: runOpts.TokenHelper, - flagAddress: runOpts.Address, - }, + BaseCommand: getBaseCommand(), }, }, nil }, @@ -745,11 +698,7 @@ func initCommands(ui, serverCmdUi cli.Ui, runOpts *RunOptions) { New: "secrets tune", UI: ui, Command: &SecretsTuneCommand{ - BaseCommand: &BaseCommand{ - UI: ui, - tokenHelper: runOpts.TokenHelper, - flagAddress: runOpts.Address, - }, + BaseCommand: getBaseCommand(), }, }, nil }, @@ -760,11 +709,7 @@ func initCommands(ui, serverCmdUi cli.Ui, runOpts *RunOptions) { New: "secrets list", UI: ui, Command: &SecretsListCommand{ - BaseCommand: &BaseCommand{ - UI: ui, - tokenHelper: runOpts.TokenHelper, - flagAddress: runOpts.Address, - }, + BaseCommand: getBaseCommand(), }, }, nil }, @@ -775,11 +720,7 @@ func initCommands(ui, serverCmdUi cli.Ui, runOpts *RunOptions) { New: "policy read\" or \"vault policy list", // lol UI: ui, Command: &PoliciesDeprecatedCommand{ - BaseCommand: &BaseCommand{ - UI: ui, - tokenHelper: runOpts.TokenHelper, - flagAddress: runOpts.Address, - }, + BaseCommand: getBaseCommand(), }, }, nil }, @@ -790,11 +731,7 @@ func initCommands(ui, serverCmdUi cli.Ui, runOpts *RunOptions) { New: "policy delete", UI: ui, Command: &PolicyDeleteCommand{ - BaseCommand: &BaseCommand{ - UI: ui, - tokenHelper: runOpts.TokenHelper, - flagAddress: runOpts.Address, - }, + BaseCommand: getBaseCommand(), }, }, nil }, @@ -805,11 +742,7 @@ func initCommands(ui, serverCmdUi cli.Ui, runOpts *RunOptions) { New: "policy write", UI: ui, Command: &PolicyWriteCommand{ - BaseCommand: &BaseCommand{ - UI: ui, - tokenHelper: runOpts.TokenHelper, - flagAddress: runOpts.Address, - }, + BaseCommand: getBaseCommand(), }, }, nil }, @@ -820,11 +753,7 @@ func initCommands(ui, serverCmdUi cli.Ui, runOpts *RunOptions) { New: "operator rekey", UI: ui, Command: &OperatorRekeyCommand{ - BaseCommand: &BaseCommand{ - UI: ui, - tokenHelper: runOpts.TokenHelper, - flagAddress: runOpts.Address, - }, + BaseCommand: getBaseCommand(), }, }, nil }, @@ -835,11 +764,7 @@ func initCommands(ui, serverCmdUi cli.Ui, runOpts *RunOptions) { New: "secrets move", UI: ui, Command: &SecretsMoveCommand{ - BaseCommand: &BaseCommand{ - UI: ui, - tokenHelper: runOpts.TokenHelper, - flagAddress: runOpts.Address, - }, + BaseCommand: getBaseCommand(), }, }, nil }, @@ -850,11 +775,7 @@ func initCommands(ui, serverCmdUi cli.Ui, runOpts *RunOptions) { New: "operator rotate", UI: ui, Command: &OperatorRotateCommand{ - BaseCommand: &BaseCommand{ - UI: ui, - tokenHelper: runOpts.TokenHelper, - flagAddress: runOpts.Address, - }, + BaseCommand: getBaseCommand(), }, }, nil }, @@ -865,11 +786,7 @@ func initCommands(ui, serverCmdUi cli.Ui, runOpts *RunOptions) { New: "operator seal", UI: ui, Command: &OperatorSealCommand{ - BaseCommand: &BaseCommand{ - UI: ui, - tokenHelper: runOpts.TokenHelper, - flagAddress: runOpts.Address, - }, + BaseCommand: getBaseCommand(), }, }, nil }, @@ -880,11 +797,7 @@ func initCommands(ui, serverCmdUi cli.Ui, runOpts *RunOptions) { New: "operator step-down", UI: ui, Command: &OperatorStepDownCommand{ - BaseCommand: &BaseCommand{ - UI: ui, - tokenHelper: runOpts.TokenHelper, - flagAddress: runOpts.Address, - }, + BaseCommand: getBaseCommand(), }, }, nil }, @@ -895,11 +808,7 @@ func initCommands(ui, serverCmdUi cli.Ui, runOpts *RunOptions) { New: "token create", UI: ui, Command: &TokenCreateCommand{ - BaseCommand: &BaseCommand{ - UI: ui, - tokenHelper: runOpts.TokenHelper, - flagAddress: runOpts.Address, - }, + BaseCommand: getBaseCommand(), }, }, nil }, @@ -910,11 +819,7 @@ func initCommands(ui, serverCmdUi cli.Ui, runOpts *RunOptions) { New: "token lookup", UI: ui, Command: &TokenLookupCommand{ - BaseCommand: &BaseCommand{ - UI: ui, - tokenHelper: runOpts.TokenHelper, - flagAddress: runOpts.Address, - }, + BaseCommand: getBaseCommand(), }, }, nil }, @@ -925,11 +830,7 @@ func initCommands(ui, serverCmdUi cli.Ui, runOpts *RunOptions) { New: "token renew", UI: ui, Command: &TokenRenewCommand{ - BaseCommand: &BaseCommand{ - UI: ui, - tokenHelper: runOpts.TokenHelper, - flagAddress: runOpts.Address, - }, + BaseCommand: getBaseCommand(), }, }, nil }, @@ -940,11 +841,7 @@ func initCommands(ui, serverCmdUi cli.Ui, runOpts *RunOptions) { New: "token revoke", UI: ui, Command: &TokenRevokeCommand{ - BaseCommand: &BaseCommand{ - UI: ui, - tokenHelper: runOpts.TokenHelper, - flagAddress: runOpts.Address, - }, + BaseCommand: getBaseCommand(), }, }, nil }, @@ -955,11 +852,7 @@ func initCommands(ui, serverCmdUi cli.Ui, runOpts *RunOptions) { New: "secrets disable", UI: ui, Command: &SecretsDisableCommand{ - BaseCommand: &BaseCommand{ - UI: ui, - tokenHelper: runOpts.TokenHelper, - flagAddress: runOpts.Address, - }, + BaseCommand: getBaseCommand(), }, }, nil }, @@ -970,11 +863,7 @@ func initCommands(ui, serverCmdUi cli.Ui, runOpts *RunOptions) { New: "operator unseal", UI: ui, Command: &OperatorUnsealCommand{ - BaseCommand: &BaseCommand{ - UI: ui, - tokenHelper: runOpts.TokenHelper, - flagAddress: runOpts.Address, - }, + BaseCommand: getBaseCommand(), }, }, nil },