mirror of
https://github.com/minio/minio
synced 2024-11-05 17:34:01 +00:00
env: Remove quotes when parsing a config env file (#13953)
The code parsing the config environment file does not remove quotes of environment variables values. This commit adds this capability.
This commit is contained in:
parent
364e27d5f2
commit
5cc16e098c
2 changed files with 34 additions and 2 deletions
|
@ -460,9 +460,21 @@ func parsEnvEntry(envEntry string) (envKV, error) {
|
|||
if len(envTokens) != 2 {
|
||||
return envKV{}, fmt.Errorf("envEntry malformed; %s, expected to be of form 'KEY=value'", envEntry)
|
||||
}
|
||||
|
||||
key := envTokens[0]
|
||||
val := envTokens[1]
|
||||
|
||||
// Remove quotes from the value if found
|
||||
if len(val) >= 2 {
|
||||
quote := val[0]
|
||||
if (quote == '"' || quote == '\'') && val[len(val)-1] == quote {
|
||||
val = val[1 : len(val)-1]
|
||||
}
|
||||
}
|
||||
|
||||
return envKV{
|
||||
Key: envTokens[0],
|
||||
Value: envTokens[1],
|
||||
Key: key,
|
||||
Value: val,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -45,6 +45,26 @@ export MINIO_ROOT_PASSWORD=minio123`,
|
|||
},
|
||||
},
|
||||
},
|
||||
// Value with double quotes
|
||||
{`export MINIO_ROOT_USER="minio"`,
|
||||
false,
|
||||
[]envKV{
|
||||
{
|
||||
Key: "MINIO_ROOT_USER",
|
||||
Value: "minio",
|
||||
},
|
||||
},
|
||||
},
|
||||
// Value with single quotes
|
||||
{`export MINIO_ROOT_USER='minio'`,
|
||||
false,
|
||||
[]envKV{
|
||||
{
|
||||
Key: "MINIO_ROOT_USER",
|
||||
Value: "minio",
|
||||
},
|
||||
},
|
||||
},
|
||||
{`
|
||||
MINIO_ROOT_USER=minio
|
||||
MINIO_ROOT_PASSWORD=minio123`,
|
||||
|
|
Loading…
Reference in a new issue