Print message when creating the config file (#3089)

master
Anis Elleuch 8 years ago committed by Harshavardhana
parent f7c20b97a1
commit a15dc5fed5
  1. 6
      cmd/config-migrate_test.go
  2. 18
      cmd/config-v9.go
  3. 2
      cmd/config-v9_test.go
  4. 5
      cmd/main.go
  5. 2
      cmd/signature-jwt_test.go
  6. 4
      cmd/signature-v2_test.go
  7. 2
      cmd/test-utils_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)
}
}

@ -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.

@ -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)
}
}

@ -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")

@ -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)
}
}

@ -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)
}

@ -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
}

Loading…
Cancel
Save