mirror of
https://github.com/minio/minio.git
synced 2025-01-26 06:03:17 -05:00
kms: initialize after cli parsing (#15076)
KMS depends on the --certs-dir flag. Ensure KMS is initialized after loading the flag.
This commit is contained in:
parent
48ff373ff7
commit
0d00f3a55b
@ -784,17 +784,22 @@ func handleCommonEnvVars() {
|
|||||||
}
|
}
|
||||||
globalActiveCred = cred
|
globalActiveCred = cred
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initialize KMS global variable after valiadating and loading the configuration.
|
||||||
|
// It depends on KMS env variables and global cli flags.
|
||||||
|
func handleKMSConfig() {
|
||||||
switch {
|
switch {
|
||||||
case env.IsSet(config.EnvKMSSecretKey) && env.IsSet(config.EnvKESEndpoint):
|
case env.IsSet(config.EnvKMSSecretKey) && env.IsSet(config.EnvKESEndpoint):
|
||||||
logger.Fatal(errors.New("ambigious KMS configuration"), fmt.Sprintf("The environment contains %q as well as %q", config.EnvKMSSecretKey, config.EnvKESEndpoint))
|
logger.Fatal(errors.New("ambigious KMS configuration"), fmt.Sprintf("The environment contains %q as well as %q", config.EnvKMSSecretKey, config.EnvKESEndpoint))
|
||||||
}
|
}
|
||||||
|
|
||||||
if env.IsSet(config.EnvKMSSecretKey) {
|
if env.IsSet(config.EnvKMSSecretKey) {
|
||||||
GlobalKMS, err = kms.Parse(env.Get(config.EnvKMSSecretKey, ""))
|
KMS, err := kms.Parse(env.Get(config.EnvKMSSecretKey, ""))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Fatal(err, "Unable to parse the KMS secret key inherited from the shell environment")
|
logger.Fatal(err, "Unable to parse the KMS secret key inherited from the shell environment")
|
||||||
}
|
}
|
||||||
|
GlobalKMS = KMS
|
||||||
}
|
}
|
||||||
if env.IsSet(config.EnvKESEndpoint) {
|
if env.IsSet(config.EnvKESEndpoint) {
|
||||||
var endpoints []string
|
var endpoints []string
|
||||||
|
@ -212,6 +212,9 @@ func StartGateway(ctx *cli.Context, gw Gateway) {
|
|||||||
// Handle gateway specific env
|
// Handle gateway specific env
|
||||||
gatewayHandleEnvVars()
|
gatewayHandleEnvVars()
|
||||||
|
|
||||||
|
// Initialize KMS configuration
|
||||||
|
handleKMSConfig()
|
||||||
|
|
||||||
// Set system resources to maximum.
|
// Set system resources to maximum.
|
||||||
setMaxResources()
|
setMaxResources()
|
||||||
|
|
||||||
|
@ -435,6 +435,9 @@ func serverMain(ctx *cli.Context) {
|
|||||||
// Handle all server command args.
|
// Handle all server command args.
|
||||||
serverHandleCmdArgs(ctx)
|
serverHandleCmdArgs(ctx)
|
||||||
|
|
||||||
|
// Initialize KMS configuration
|
||||||
|
handleKMSConfig()
|
||||||
|
|
||||||
// Set node name, only set for distributed setup.
|
// Set node name, only set for distributed setup.
|
||||||
globalConsoleSys.SetNodeName(globalLocalNodeName)
|
globalConsoleSys.SetNodeName(globalLocalNodeName)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user