mirror of
https://github.com/minio/minio.git
synced 2025-04-01 02:03:42 -04:00
Skip commented lines when parsing MinIO configuration file (#14710)
Signed-off-by: Lenin Alevski <alevsk.8772@gmail.com>
This commit is contained in:
parent
16431d222c
commit
a3e317773a
@ -487,6 +487,13 @@ func parsEnvEntry(envEntry string) (envKV, error) {
|
|||||||
key := envTokens[0]
|
key := envTokens[0]
|
||||||
val := envTokens[1]
|
val := envTokens[1]
|
||||||
|
|
||||||
|
if strings.HasPrefix(key, "#") {
|
||||||
|
// Skip commented lines
|
||||||
|
return envKV{
|
||||||
|
Skip: true,
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
// Remove quotes from the value if found
|
// Remove quotes from the value if found
|
||||||
if len(val) >= 2 {
|
if len(val) >= 2 {
|
||||||
quote := val[0]
|
quote := val[0]
|
||||||
|
@ -134,6 +134,24 @@ export MINIO_ROOT_PASSWORD=minio123`,
|
|||||||
true,
|
true,
|
||||||
nil,
|
nil,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
`
|
||||||
|
# MINIO_ROOT_USER=minioadmin
|
||||||
|
# MINIO_ROOT_PASSWORD=minioadmin
|
||||||
|
MINIO_ROOT_USER=minio
|
||||||
|
MINIO_ROOT_PASSWORD=minio123`,
|
||||||
|
false,
|
||||||
|
[]envKV{
|
||||||
|
{
|
||||||
|
Key: "MINIO_ROOT_USER",
|
||||||
|
Value: "minio",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
Key: "MINIO_ROOT_PASSWORD",
|
||||||
|
Value: "minio123",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
for _, testCase := range testCases {
|
for _, testCase := range testCases {
|
||||||
testCase := testCase
|
testCase := testCase
|
||||||
@ -153,6 +171,11 @@ export MINIO_ROOT_PASSWORD=minio123`,
|
|||||||
if err == nil && testCase.expectedErr {
|
if err == nil && testCase.expectedErr {
|
||||||
t.Error(errors.New("expected error, found success"))
|
t.Error(errors.New("expected error, found success"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(ekvs) != len(testCase.expectedEkvs) {
|
||||||
|
t.Errorf("expected %v keys, got %v keys", len(testCase.expectedEkvs), len(ekvs))
|
||||||
|
}
|
||||||
|
|
||||||
if !reflect.DeepEqual(ekvs, testCase.expectedEkvs) {
|
if !reflect.DeepEqual(ekvs, testCase.expectedEkvs) {
|
||||||
t.Errorf("expected %v, got %v", testCase.expectedEkvs, ekvs)
|
t.Errorf("expected %v, got %v", testCase.expectedEkvs, ekvs)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user