Remove old hooks and start calling new ones. (#23550)

This commit is contained in:
Nick Cabatoff 2023-10-06 12:16:19 -04:00 committed by GitHub
parent baa4dbe8e2
commit 5bf40c6e2d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 61 deletions

View file

@ -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
}

View file

@ -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

View file

@ -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 := `

View file

@ -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
}