mirror of
https://github.com/minio/minio.git
synced 2025-01-23 04:33:15 -05:00
Print message when creating the config file (#3089)
This commit is contained in:
parent
f7c20b97a1
commit
a15dc5fed5
@ -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…
x
Reference in New Issue
Block a user