mirror of
https://github.com/pgsty/minio.git
synced 2026-07-19 20:20:25 +03:00
Extend further validation of config values (#8469)
- This PR allows config KVS to be validated properly without being affected by ENV overrides, rejects invalid values during set operation - Expands unit tests and refactors the error handling for notification targets, returns error instead of ignoring targets for invalid KVS - Does all the prep-work for implementing safe-mode style operation for MinIO server, introduces a new global variable to toggle safe mode based operations NOTE: this PR itself doesn't provide safe mode operations
This commit is contained in:
committed by
kannappanr
parent
599aae5ba6
commit
9e7a3e6adc
Vendored
+3
@@ -89,6 +89,9 @@ func parseCacheDrives(drives []string) ([]string, error) {
|
||||
}
|
||||
|
||||
for _, d := range endpoints {
|
||||
if len(d) == 0 {
|
||||
return nil, config.ErrInvalidCacheDrivesValue(nil).Msg("cache dir cannot be an empty path")
|
||||
}
|
||||
if !filepath.IsAbs(d) {
|
||||
return nil, config.ErrInvalidCacheDrivesValue(nil).Msg("cache dir should be absolute path: %s", d)
|
||||
}
|
||||
|
||||
Vendored
+10
-2
@@ -30,11 +30,15 @@ func TestParseCacheDrives(t *testing.T) {
|
||||
expectedPatterns []string
|
||||
success bool
|
||||
}{
|
||||
// valid input
|
||||
// Invalid input
|
||||
|
||||
{"bucket1/*;*.png;images/trip/barcelona/*", []string{}, false},
|
||||
{"bucket1", []string{}, false},
|
||||
{";;;", []string{}, false},
|
||||
{",;,;,;", []string{}, false},
|
||||
}
|
||||
|
||||
// Valid inputs
|
||||
if runtime.GOOS == "windows" {
|
||||
testCases = append(testCases, struct {
|
||||
driveStr string
|
||||
@@ -91,8 +95,12 @@ func TestParseCacheExclude(t *testing.T) {
|
||||
expectedPatterns []string
|
||||
success bool
|
||||
}{
|
||||
// valid input
|
||||
// Invalid input
|
||||
{"/home/drive1;/home/drive2;/home/drive3", []string{}, false},
|
||||
{"/", []string{}, false},
|
||||
{";;;", []string{}, false},
|
||||
|
||||
// valid input
|
||||
{"bucket1/*;*.png;images/trip/barcelona/*", []string{"bucket1/*", "*.png", "images/trip/barcelona/*"}, true},
|
||||
{"bucket1", []string{"bucket1"}, true},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user