Remove globalQuiet and globalConfigDir global variables (#3830)

This commit is contained in:
Bala FA
2017-03-03 03:51:30 +05:30
committed by Harshavardhana
parent 208dd15245
commit 98d17d2a97
18 changed files with 178 additions and 364 deletions
+4 -31
View File
@@ -31,7 +31,7 @@ var (
globalFlags = []cli.Flag{
cli.StringFlag{
Name: "config-dir, C",
Value: mustGetConfigPath(),
Value: getConfigDir(),
Usage: "Path to configuration directory.",
},
cli.BoolFlag{
@@ -133,26 +133,10 @@ func registerApp() *cli.App {
return app
}
// Verify main command syntax.
func checkMainSyntax(c *cli.Context) {
configPath, err := getConfigPath()
if err != nil {
console.Fatalf("Unable to obtain user's home directory. \nError: %s\n", err)
}
if configPath == "" {
console.Fatalln("Config directory cannot be empty, please specify --config-dir <directoryname>.")
}
}
// Check for updates and print a notification message
func checkUpdate() {
// Do not print update messages, if quiet flag is set.
if !globalQuiet {
older, downloadURL, err := getUpdateInfo(1 * time.Second)
if err != nil {
// Its OK to ignore any errors during getUpdateInfo() here.
return
}
// Its OK to ignore any errors during getUpdateInfo() here.
if older, downloadURL, err := getUpdateInfo(1 * time.Second); err == nil {
if older > time.Duration(0) {
console.Println(colorizeUpdateMessage(downloadURL, older))
}
@@ -179,7 +163,7 @@ func initConfig() {
if err := newConfig(envs); err != nil {
console.Fatalf("Unable to initialize minio config for the first time. Err: %s.\n", err)
}
console.Println("Created minio configuration file successfully at " + mustGetConfigPath())
console.Println("Created minio configuration file successfully at " + getConfigDir())
return
}
@@ -194,12 +178,6 @@ func initConfig() {
// Generic Minio initialization to create/load config, prepare loggers, etc..
func minioInit(ctx *cli.Context) {
// Set global variables after parsing passed arguments
setGlobalsFromContext(ctx)
// Sets new config directory.
setGlobalConfigPath(globalConfigDir)
// Is TLS configured?.
globalIsSSL = isSSL()
@@ -217,11 +195,6 @@ func minioInit(ctx *cli.Context) {
// Main main for minio server.
func Main(args []string, exitFn func(int)) {
app := registerApp()
app.Before = func(c *cli.Context) error {
// Valid input arguments to main.
checkMainSyntax(c)
return nil
}
// Start profiler if env is set.
if profiler := os.Getenv("_MINIO_PROFILER"); profiler != "" {