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
|
// 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)
|
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
|
// 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)
|
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
|
// 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)
|
t.Fatalf("Unable to initialize from updated config file %s", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,8 +42,8 @@ type serverConfigV9 struct {
|
|||||||
rwMutex *sync.RWMutex
|
rwMutex *sync.RWMutex
|
||||||
}
|
}
|
||||||
|
|
||||||
// initConfig - initialize server config. config version (called only once).
|
// initConfig - initialize server config and indicate if we are creating a new file or we are just loading
|
||||||
func initConfig() error {
|
func initConfig() (bool, error) {
|
||||||
if !isConfigFileExists() {
|
if !isConfigFileExists() {
|
||||||
// Initialize server config.
|
// Initialize server config.
|
||||||
srvCfg := &serverConfigV9{}
|
srvCfg := &serverConfigV9{}
|
||||||
@ -73,38 +73,38 @@ func initConfig() error {
|
|||||||
// Create config path.
|
// Create config path.
|
||||||
err := createConfigPath()
|
err := createConfigPath()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return false, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Save the new config globally.
|
// Save the new config globally.
|
||||||
serverConfig = srvCfg
|
serverConfig = srvCfg
|
||||||
|
|
||||||
// Save config into file.
|
// Save config into file.
|
||||||
return serverConfig.Save()
|
return true, serverConfig.Save()
|
||||||
}
|
}
|
||||||
configFile, err := getConfigFile()
|
configFile, err := getConfigFile()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return false, err
|
||||||
}
|
}
|
||||||
if _, err = os.Stat(configFile); err != nil {
|
if _, err = os.Stat(configFile); err != nil {
|
||||||
return err
|
return false, err
|
||||||
}
|
}
|
||||||
srvCfg := &serverConfigV9{}
|
srvCfg := &serverConfigV9{}
|
||||||
srvCfg.Version = globalMinioConfigVersion
|
srvCfg.Version = globalMinioConfigVersion
|
||||||
srvCfg.rwMutex = &sync.RWMutex{}
|
srvCfg.rwMutex = &sync.RWMutex{}
|
||||||
qc, err := quick.New(srvCfg)
|
qc, err := quick.New(srvCfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return false, err
|
||||||
}
|
}
|
||||||
if err := qc.Load(configFile); err != nil {
|
if err := qc.Load(configFile); err != nil {
|
||||||
return err
|
return false, err
|
||||||
}
|
}
|
||||||
// Save the loaded config globally.
|
// Save the loaded config globally.
|
||||||
serverConfig = srvCfg
|
serverConfig = srvCfg
|
||||||
// Set the version properly after the unmarshalled json is loaded.
|
// Set the version properly after the unmarshalled json is loaded.
|
||||||
serverConfig.Version = globalMinioConfigVersion
|
serverConfig.Version = globalMinioConfigVersion
|
||||||
|
|
||||||
return nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// serverConfig server config.
|
// serverConfig server config.
|
||||||
|
@ -101,7 +101,7 @@ func TestServerConfig(t *testing.T) {
|
|||||||
setGlobalConfigPath(rootPath)
|
setGlobalConfigPath(rootPath)
|
||||||
|
|
||||||
// Initialize server config.
|
// Initialize server config.
|
||||||
if err := initConfig(); err != nil {
|
if _, err := initConfig(); err != nil {
|
||||||
t.Fatalf("Unable to initialize from updated config file %s", err)
|
t.Fatalf("Unable to initialize from updated config file %s", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -171,8 +171,11 @@ func Main() {
|
|||||||
migrate()
|
migrate()
|
||||||
|
|
||||||
// Initialize config.
|
// Initialize config.
|
||||||
err := initConfig()
|
configCreated, err := initConfig()
|
||||||
fatalIf(err, "Unable to initialize minio config.")
|
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.
|
// Fetch access keys from environment variables and update the config.
|
||||||
accessKey := os.Getenv("MINIO_ACCESS_KEY")
|
accessKey := os.Getenv("MINIO_ACCESS_KEY")
|
||||||
|
@ -99,7 +99,7 @@ func TestNewJWT(t *testing.T) {
|
|||||||
for _, testCase := range testCases {
|
for _, testCase := range testCases {
|
||||||
setGlobalConfigPath(testCase.dirPath)
|
setGlobalConfigPath(testCase.dirPath)
|
||||||
if testCase.init {
|
if testCase.init {
|
||||||
if err := initConfig(); err != nil {
|
if _, err := initConfig(); err != nil {
|
||||||
t.Fatalf("unable initialize config file, %s", err)
|
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.
|
// TestValidateV2AuthHeader - Tests validate the logic of V2 Authorization header validator.
|
||||||
func TestValidateV2AuthHeader(t *testing.T) {
|
func TestValidateV2AuthHeader(t *testing.T) {
|
||||||
// Initialize server config.
|
// Initialize server config.
|
||||||
if err := initConfig(); err != nil {
|
if _, err := initConfig(); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -182,7 +182,7 @@ func TestValidateV2AuthHeader(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestDoesPolicySignatureV2Match(t *testing.T) {
|
func TestDoesPolicySignatureV2Match(t *testing.T) {
|
||||||
if err := initConfig(); err != nil {
|
if _, err := initConfig(); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -488,7 +488,7 @@ func newTestConfig(bucketLocation string) (rootPath string, err error) {
|
|||||||
setGlobalConfigPath(rootPath)
|
setGlobalConfigPath(rootPath)
|
||||||
|
|
||||||
// Initialize server config.
|
// Initialize server config.
|
||||||
if err = initConfig(); err != nil {
|
if _, err = initConfig(); err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user