From 5bf40c6e2da5b9f761d8e10f0bd781a524ceb8aa Mon Sep 17 00:00:00 2001 From: Nick Cabatoff Date: Fri, 6 Oct 2023 12:16:19 -0400 Subject: [PATCH] Remove old hooks and start calling new ones. (#23550) --- command/commands.go | 5 +---- command/server.go | 18 ++++++------------ command/server/config.go | 18 +++--------------- command/server_util.go | 30 ------------------------------ 4 files changed, 10 insertions(+), 61 deletions(-) delete mode 100644 command/server_util.go diff --git a/command/commands.go b/command/commands.go index 7a03d5569a..f5b398a8c9 100644 --- a/command/commands.go +++ b/command/commands.go @@ -240,9 +240,6 @@ var ( DefaultMount: "userpass", }, } - - // TODO remove this once entInitCommands has replaced it - initCommandsEnt = func(ui, serverCmdUi cli.Ui, runOpts *RunOptions, commands map[string]cli.CommandFactory) {} ) func initCommands(ui, serverCmdUi cli.Ui, runOpts *RunOptions) map[string]cli.CommandFactory { @@ -907,7 +904,7 @@ func initCommands(ui, serverCmdUi cli.Ui, runOpts *RunOptions) map[string]cli.Co }, } - initCommandsEnt(ui, serverCmdUi, runOpts, commands) + entInitCommands(ui, serverCmdUi, runOpts, commands) return commands } diff --git a/command/server.go b/command/server.go index 7f8bd2d981..59f05437dc 100644 --- a/command/server.go +++ b/command/server.go @@ -80,12 +80,6 @@ var ( var memProfilerEnabled = false -// TODO remove this once entEnableFourClusterDev has replaced it -var enableFourClusterDev = func(c *ServerCommand, base *vault.CoreConfig, info map[string]string, infoKeys []string, devListenAddress, tempDir string) int { - c.logger.Error("-dev-four-cluster only supported in enterprise Vault") - return 1 -} - const ( storageMigrationLock = "core/migration" @@ -677,7 +671,7 @@ func (c *ServerCommand) runRecoveryMode() int { infoKeys = append(infoKeys, "go version") info["go version"] = runtime.Version() - fipsStatus := getFIPSInfoKey() + fipsStatus := entGetFIPSInfoKey() if fipsStatus != "" { infoKeys = append(infoKeys, "fips") info["fips"] = fipsStatus @@ -1327,7 +1321,7 @@ func (c *ServerCommand) Run(args []string) int { c.SubloggerAdder = &coreConfig if c.flagDevFourCluster { - return enableFourClusterDev(c, &coreConfig, info, infoKeys, c.flagDevListenAddr, os.Getenv("VAULT_DEV_TEMP_DIR")) + return entEnableFourClusterDev(c, &coreConfig, info, infoKeys, c.flagDevListenAddr, os.Getenv("VAULT_DEV_TEMP_DIR")) } if allowPendingRemoval := os.Getenv(consts.EnvVaultAllowPendingRemovalMounts); allowPendingRemoval != "" { @@ -1379,9 +1373,9 @@ func (c *ServerCommand) Run(args []string) int { } // Apply any enterprise configuration onto the coreConfig. - adjustCoreConfigForEnt(config, &coreConfig) + entAdjustCoreConfig(config, &coreConfig) - if !storageSupportedForEnt(&coreConfig) { + if !entCheckStorageType(&coreConfig) { c.UI.Warn("") c.UI.Warn(wrapAtLength(fmt.Sprintf("WARNING: storage configured to use %q which is not supported for Vault Enterprise, must be \"raft\" or \"consul\"", coreConfig.StorageType))) c.UI.Warn("") @@ -1488,7 +1482,7 @@ func (c *ServerCommand) Run(args []string) int { infoKeys = append(infoKeys, "go version") info["go version"] = runtime.Version() - fipsStatus := getFIPSInfoKey() + fipsStatus := entGetFIPSInfoKey() if fipsStatus != "" { infoKeys = append(infoKeys, "fips") info["fips"] = fipsStatus @@ -2137,7 +2131,7 @@ func (c *ServerCommand) enableThreeNodeDevCluster(base *vault.CoreConfig, info m infoKeys = append(infoKeys, "go version") info["go version"] = runtime.Version() - fipsStatus := getFIPSInfoKey() + fipsStatus := entGetFIPSInfoKey() if fipsStatus != "" { infoKeys = append(infoKeys, "fips") info["fips"] = fipsStatus diff --git a/command/server/config.go b/command/server/config.go index 5502fb0ba9..7b7d73f912 100644 --- a/command/server/config.go +++ b/command/server/config.go @@ -34,15 +34,8 @@ const ( VaultDevKeyFilename = "vault-key.pem" ) -var ( - // TODO remove once entValidateConfig has replaced it - entConfigValidate = func(_ *Config, _ string) []configutil.ConfigError { - return nil - } - - // Modified internally for testing. - validExperiments = experiments.ValidExperiments() -) +// Modified internally for testing. +var validExperiments = experiments.ValidExperiments() // Config is the configuration for the vault server. type Config struct { @@ -138,15 +131,10 @@ func (c *Config) Validate(sourceFilePath string) []configutil.ConfigError { for _, l := range c.Listeners { results = append(results, l.Validate(sourceFilePath)...) } - results = append(results, c.validateEnt(sourceFilePath)...) + results = append(results, entValidateConfig(c, sourceFilePath)...) return results } -// TODO remove once entValidateConfig is present in both repos -func (c *Config) validateEnt(sourceFilePath string) []configutil.ConfigError { - return entConfigValidate(c, sourceFilePath) -} - // DevConfig is a Config that is used for dev mode of Vault. func DevConfig(storageType string) (*Config, error) { hclStr := ` diff --git a/command/server_util.go b/command/server_util.go deleted file mode 100644 index 470e09d437..0000000000 --- a/command/server_util.go +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) HashiCorp, Inc. -// SPDX-License-Identifier: BUSL-1.1 - -package command - -import ( - "github.com/hashicorp/vault/command/server" - "github.com/hashicorp/vault/vault" -) - -var ( - // TODO remove once entAdjustCoreConfig has replaced it - adjustCoreConfigForEnt = adjustCoreConfigForEntNoop - // TODO remove once entCheckStorageType has replaced it - storageSupportedForEnt = checkStorageTypeForEntNoop -) - -func adjustCoreConfigForEntNoop(config *server.Config, coreConfig *vault.CoreConfig) { -} - -// TODO remove once entGetFIPSInfoKey has replaced it -var getFIPSInfoKey = getFIPSInfoKeyNoop - -func getFIPSInfoKeyNoop() string { - return "" -} - -func checkStorageTypeForEntNoop(coreConfig *vault.CoreConfig) bool { - return true -}