feat: use S3_ env prefix with MINIO_ backwards compatibility
- Override EnvPrefix to "S3_" instead of importing MINIO_ from madmin-go - Add EnvLegacyPrefix "MINIO_" constant for backwards compat - Add MINIO_ fallback in ResolveConfigParam for subsystem env vars - Add MINIO_ROOT_USER/PASSWORD fallback in credential loading - Add MINIO_ access key fallback in credential loading - Skip legacy MINIO_ vars in bootstrap peer sync
This commit is contained in:
@@ -117,6 +117,11 @@ var skipEnvs = map[string]struct{}{
|
||||
"S3_OPERATOR_VERSION": {},
|
||||
"S3_VSPHERE_PLUGIN_VERSION": {},
|
||||
"S3_CI_CD": {},
|
||||
// Legacy MINIO_ prefix backwards compatibility
|
||||
"MINIO_ROOT_USER": {},
|
||||
"MINIO_ROOT_PASSWORD": {},
|
||||
"MINIO_ACCESS_KEY": {},
|
||||
"MINIO_SECRET_KEY": {},
|
||||
}
|
||||
|
||||
func getServerSystemCfg() *ServerSystemConfig {
|
||||
|
||||
+22
-9
@@ -813,19 +813,24 @@ func serverHandleEnvVars() {
|
||||
|
||||
// Check if the supported credential env vars,
|
||||
// "S3_ROOT_USER" and "S3_ROOT_PASSWORD" are provided
|
||||
// Also check legacy "MINIO_ROOT_USER" / "MINIO_ROOT_PASSWORD" for backwards compat
|
||||
// Warn user if deprecated environment variables,
|
||||
// "S3_ACCESS_KEY" and "S3_SECRET_KEY", are defined
|
||||
// Check all error conditions first
|
||||
hasRootUser := env.IsSet(config.EnvRootUser) || env.IsSet("MINIO_ROOT_USER")
|
||||
hasRootPassword := env.IsSet(config.EnvRootPassword) || env.IsSet("MINIO_ROOT_PASSWORD")
|
||||
hasAccessKey := env.IsSet(config.EnvAccessKey) || env.IsSet("MINIO_ACCESS_KEY")
|
||||
hasSecretKey := env.IsSet(config.EnvSecretKey) || env.IsSet("MINIO_SECRET_KEY")
|
||||
//nolint:gocritic
|
||||
if !env.IsSet(config.EnvRootUser) && env.IsSet(config.EnvRootPassword) {
|
||||
logger.Fatal(config.ErrMissingEnvCredentialRootUser(nil), "Unable to start MinIO")
|
||||
} else if env.IsSet(config.EnvRootUser) && !env.IsSet(config.EnvRootPassword) {
|
||||
logger.Fatal(config.ErrMissingEnvCredentialRootPassword(nil), "Unable to start MinIO")
|
||||
} else if !env.IsSet(config.EnvRootUser) && !env.IsSet(config.EnvRootPassword) {
|
||||
if !env.IsSet(config.EnvAccessKey) && env.IsSet(config.EnvSecretKey) {
|
||||
logger.Fatal(config.ErrMissingEnvCredentialAccessKey(nil), "Unable to start MinIO")
|
||||
} else if env.IsSet(config.EnvAccessKey) && !env.IsSet(config.EnvSecretKey) {
|
||||
logger.Fatal(config.ErrMissingEnvCredentialSecretKey(nil), "Unable to start MinIO")
|
||||
if !hasRootUser && hasRootPassword {
|
||||
logger.Fatal(config.ErrMissingEnvCredentialRootUser(nil), "Unable to start S3")
|
||||
} else if hasRootUser && !hasRootPassword {
|
||||
logger.Fatal(config.ErrMissingEnvCredentialRootPassword(nil), "Unable to start S3")
|
||||
} else if !hasRootUser && !hasRootPassword {
|
||||
if !hasAccessKey && hasSecretKey {
|
||||
logger.Fatal(config.ErrMissingEnvCredentialAccessKey(nil), "Unable to start S3")
|
||||
} else if hasAccessKey && !hasSecretKey {
|
||||
logger.Fatal(config.ErrMissingEnvCredentialSecretKey(nil), "Unable to start S3")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -842,10 +847,18 @@ func loadRootCredentials() auth.Credentials {
|
||||
if env.IsSet(config.EnvRootUser) && env.IsSet(config.EnvRootPassword) {
|
||||
user = env.Get(config.EnvRootUser, "")
|
||||
password = env.Get(config.EnvRootPassword, "")
|
||||
} else if env.IsSet("MINIO_ROOT_USER") && env.IsSet("MINIO_ROOT_PASSWORD") {
|
||||
// Legacy MINIO_ prefix backwards compatibility
|
||||
user = env.Get("MINIO_ROOT_USER", "")
|
||||
password = env.Get("MINIO_ROOT_PASSWORD", "")
|
||||
} else if env.IsSet(config.EnvAccessKey) && env.IsSet(config.EnvSecretKey) {
|
||||
user = env.Get(config.EnvAccessKey, "")
|
||||
password = env.Get(config.EnvSecretKey, "")
|
||||
legacyCredentials = true
|
||||
} else if env.IsSet("MINIO_ACCESS_KEY") && env.IsSet("MINIO_SECRET_KEY") {
|
||||
user = env.Get("MINIO_ACCESS_KEY", "")
|
||||
password = env.Get("MINIO_SECRET_KEY", "")
|
||||
legacyCredentials = true
|
||||
} else if globalServerCtxt.RootUser != "" && globalServerCtxt.RootPwd != "" {
|
||||
user, password = globalServerCtxt.RootUser, globalServerCtxt.RootPwd
|
||||
}
|
||||
|
||||
@@ -228,8 +228,9 @@ const (
|
||||
KvDoubleQuote = madmin.KvDoubleQuote
|
||||
KvSingleQuote = madmin.KvSingleQuote
|
||||
|
||||
// Env prefix used for all envs in MinIO
|
||||
EnvPrefix = madmin.EnvPrefix
|
||||
// Env prefix used for all envs in Hanzo S3
|
||||
EnvPrefix = "S3_"
|
||||
EnvLegacyPrefix = "MINIO_"
|
||||
EnvWordDelimiter = madmin.EnvWordDelimiter
|
||||
)
|
||||
|
||||
@@ -1232,13 +1233,21 @@ func (c Config) ResolveConfigParam(subSys, target, cfgParam string, redactSecret
|
||||
|
||||
envVar := getEnvVarName(subSys, target, cfgParam)
|
||||
|
||||
// Lookup Env var.
|
||||
// Lookup Env var (S3_ prefix).
|
||||
value = env.Get(envVar, "")
|
||||
if value != "" {
|
||||
cs = ValueSourceEnv
|
||||
return value, cs, isRedacted
|
||||
}
|
||||
|
||||
// Fallback: check legacy MINIO_ prefix for backwards compatibility.
|
||||
legacyEnvVar := EnvLegacyPrefix + envVar[len(EnvPrefix):]
|
||||
value = env.Get(legacyEnvVar, "")
|
||||
if value != "" {
|
||||
cs = ValueSourceEnv
|
||||
return value, cs, isRedacted
|
||||
}
|
||||
|
||||
// Lookup config store.
|
||||
if subSysStore, ok := c[subSys]; ok {
|
||||
if kvs, ok2 := subSysStore[target]; ok2 {
|
||||
|
||||
Reference in New Issue
Block a user