diff --git a/cmd/config-migrate_test.go b/cmd/config-migrate_test.go index c7760a01e..4da55ac73 100644 --- a/cmd/config-migrate_test.go +++ b/cmd/config-migrate_test.go @@ -53,7 +53,7 @@ func TestServerConfigMigrateV1(t *testing.T) { } // Initialize server config and check again if everything is fine - if err := initConfig(); err != nil { + if _, err := initConfig(); err != nil { t.Fatalf("Unable to initialize from updated config file %s", err) } } @@ -134,7 +134,7 @@ func TestServerConfigMigrateV2toV9(t *testing.T) { } // Initialize server config and check again if everything is fine - if err := initConfig(); err != nil { + if _, err := initConfig(); err != nil { t.Fatalf("Unable to initialize from updated config file %s", err) } @@ -153,7 +153,7 @@ func TestServerConfigMigrateV2toV9(t *testing.T) { } // Initialize server config and check again if everything is fine - if err := initConfig(); err != nil { + if _, err := initConfig(); err != nil { t.Fatalf("Unable to initialize from updated config file %s", err) } } diff --git a/cmd/config-v9.go b/cmd/config-v9.go index 0e9691438..f462641c9 100644 --- a/cmd/config-v9.go +++ b/cmd/config-v9.go @@ -42,8 +42,8 @@ type serverConfigV9 struct { rwMutex *sync.RWMutex } -// initConfig - initialize server config. config version (called only once). -func initConfig() error { +// initConfig - initialize server config and indicate if we are creating a new file or we are just loading +func initConfig() (bool, error) { if !isConfigFileExists() { // Initialize server config. srvCfg := &serverConfigV9{} @@ -73,38 +73,38 @@ func initConfig() error { // Create config path. err := createConfigPath() if err != nil { - return err + return false, err } // Save the new config globally. serverConfig = srvCfg // Save config into file. - return serverConfig.Save() + return true, serverConfig.Save() } configFile, err := getConfigFile() if err != nil { - return err + return false, err } if _, err = os.Stat(configFile); err != nil { - return err + return false, err } srvCfg := &serverConfigV9{} srvCfg.Version = globalMinioConfigVersion srvCfg.rwMutex = &sync.RWMutex{} qc, err := quick.New(srvCfg) if err != nil { - return err + return false, err } if err := qc.Load(configFile); err != nil { - return err + return false, err } // Save the loaded config globally. serverConfig = srvCfg // Set the version properly after the unmarshalled json is loaded. serverConfig.Version = globalMinioConfigVersion - return nil + return false, nil } // serverConfig server config. diff --git a/cmd/config-v7_test.go b/cmd/config-v9_test.go similarity index 98% rename from cmd/config-v7_test.go rename to cmd/config-v9_test.go index 4eecfde05..651529f5d 100644 --- a/cmd/config-v7_test.go +++ b/cmd/config-v9_test.go @@ -101,7 +101,7 @@ func TestServerConfig(t *testing.T) { setGlobalConfigPath(rootPath) // Initialize server config. - if err := initConfig(); err != nil { + if _, err := initConfig(); err != nil { t.Fatalf("Unable to initialize from updated config file %s", err) } } diff --git a/cmd/main.go b/cmd/main.go index 7a2c770e5..d0eac02be 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -171,8 +171,11 @@ func Main() { migrate() // Initialize config. - err := initConfig() + configCreated, err := initConfig() fatalIf(err, "Unable to initialize minio config.") + if configCreated { + console.Println("Created minio configuration file at " + mustGetConfigPath()) + } // Fetch access keys from environment variables and update the config. accessKey := os.Getenv("MINIO_ACCESS_KEY") diff --git a/cmd/signature-jwt_test.go b/cmd/signature-jwt_test.go index ed30dcd47..3e72d5c52 100644 --- a/cmd/signature-jwt_test.go +++ b/cmd/signature-jwt_test.go @@ -99,7 +99,7 @@ func TestNewJWT(t *testing.T) { for _, testCase := range testCases { setGlobalConfigPath(testCase.dirPath) if testCase.init { - if err := initConfig(); err != nil { + if _, err := initConfig(); err != nil { t.Fatalf("unable initialize config file, %s", err) } } diff --git a/cmd/signature-v2_test.go b/cmd/signature-v2_test.go index 24c8a8d24..39f0557bc 100644 --- a/cmd/signature-v2_test.go +++ b/cmd/signature-v2_test.go @@ -108,7 +108,7 @@ func TestDoesPresignedV2SignatureMatch(t *testing.T) { // TestValidateV2AuthHeader - Tests validate the logic of V2 Authorization header validator. func TestValidateV2AuthHeader(t *testing.T) { // Initialize server config. - if err := initConfig(); err != nil { + if _, err := initConfig(); err != nil { t.Fatal(err) } @@ -182,7 +182,7 @@ func TestValidateV2AuthHeader(t *testing.T) { } func TestDoesPolicySignatureV2Match(t *testing.T) { - if err := initConfig(); err != nil { + if _, err := initConfig(); err != nil { t.Fatal(err) } diff --git a/cmd/test-utils_test.go b/cmd/test-utils_test.go index 020f36b93..2950d1216 100644 --- a/cmd/test-utils_test.go +++ b/cmd/test-utils_test.go @@ -488,7 +488,7 @@ func newTestConfig(bucketLocation string) (rootPath string, err error) { setGlobalConfigPath(rootPath) // Initialize server config. - if err = initConfig(); err != nil { + if _, err = initConfig(); err != nil { return "", err }