mirror of
https://github.com/minio/minio.git
synced 2025-11-09 21:49:46 -05:00
browser-flag: wrapped bool type denotes browser on/off flag. (#3963)
Statically typed BrowserFlag prevents any arbitrary string value usage. The wrapped bool marshals/unmarshals JSON according to the typed value ie string value "on" represents boolean true and "off" as boolean false.
This commit is contained in:
@@ -96,7 +96,7 @@ func checkUpdate(mode string) {
|
||||
// envParams holds all env parameters
|
||||
type envParams struct {
|
||||
creds credential
|
||||
browser string
|
||||
browser BrowserFlag
|
||||
}
|
||||
|
||||
func migrate() {
|
||||
@@ -139,20 +139,21 @@ func initConfig() {
|
||||
globalIsEnvCreds = true
|
||||
}
|
||||
|
||||
browser := os.Getenv("MINIO_BROWSER")
|
||||
if browser != "" {
|
||||
if !(strings.EqualFold(browser, "off") || strings.EqualFold(browser, "on")) {
|
||||
fatalIf(errors.New("invalid value"), "‘%s’ in MINIO_BROWSER environment variable.", browser)
|
||||
}
|
||||
|
||||
// browser Envs are set globally, this doesn't represent
|
||||
// if browser is turned off or on.
|
||||
globalIsEnvBrowser = true
|
||||
}
|
||||
|
||||
envs := envParams{
|
||||
creds: cred,
|
||||
browser: browser,
|
||||
browser: BrowserFlag(true),
|
||||
}
|
||||
|
||||
if browser := os.Getenv("MINIO_BROWSER"); browser != "" {
|
||||
browserFlag, err := ParseBrowserFlag(browser)
|
||||
if err != nil {
|
||||
fatalIf(errors.New("invalid value"), "Unknown value ‘%s’ in MINIO_BROWSER environment variable.", browser)
|
||||
}
|
||||
|
||||
// browser Envs are set globally, this does not represent
|
||||
// if browser is turned off or on.
|
||||
globalIsEnvBrowser = true
|
||||
envs.browser = browserFlag
|
||||
}
|
||||
|
||||
// Config file does not exist, we create it fresh and return upon success.
|
||||
|
||||
Reference in New Issue
Block a user