mirror of
https://github.com/minio/minio.git
synced 2025-04-19 18:17:30 -04:00
Rename config.json in config-dir with '.deprecated' extension (#6446)
Fixes #6444
This commit is contained in:
parent
5c0b98abf0
commit
12b4971b70
@ -23,6 +23,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"runtime"
|
"runtime"
|
||||||
"time"
|
"time"
|
||||||
@ -227,6 +228,8 @@ func NewConfigSys() *ConfigSys {
|
|||||||
|
|
||||||
// Migrates ${HOME}/.minio/config.json to '<export_path>/.minio.sys/config/config.json'
|
// Migrates ${HOME}/.minio/config.json to '<export_path>/.minio.sys/config/config.json'
|
||||||
func migrateConfigToMinioSys(objAPI ObjectLayer) error {
|
func migrateConfigToMinioSys(objAPI ObjectLayer) error {
|
||||||
|
defer os.Rename(getConfigFile(), getConfigFile()+".deprecated")
|
||||||
|
|
||||||
// Verify if backend already has the file.
|
// Verify if backend already has the file.
|
||||||
if err := checkServerConfig(context.Background(), objAPI); err != errConfigNotFound {
|
if err := checkServerConfig(context.Background(), objAPI); err != errConfigNotFound {
|
||||||
return err
|
return err
|
||||||
@ -234,8 +237,14 @@ func migrateConfigToMinioSys(objAPI ObjectLayer) error {
|
|||||||
|
|
||||||
var config = &serverConfig{}
|
var config = &serverConfig{}
|
||||||
if _, err := Load(getConfigFile(), config); err != nil {
|
if _, err := Load(getConfigFile(), config); err != nil {
|
||||||
|
if !os.IsNotExist(err) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
// Read from deprecate file as well if necessary.
|
||||||
|
if _, err = Load(getConfigFile()+".deprecated", config); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return saveServerConfig(context.Background(), objAPI, config)
|
return saveServerConfig(context.Background(), objAPI, config)
|
||||||
}
|
}
|
||||||
@ -258,13 +267,13 @@ func initConfig(objAPI ObjectLayer) error {
|
|||||||
if err := migrateConfig(); err != nil {
|
if err := migrateConfig(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// Migrates ${HOME}/.minio/config.json to '<export_path>/.minio.sys/config/config.json'
|
// Migrates ${HOME}/.minio/config.json or config.json.deprecated
|
||||||
|
// to '<export_path>/.minio.sys/config/config.json'
|
||||||
if err := migrateConfigToMinioSys(objAPI); err != nil {
|
if err := migrateConfigToMinioSys(objAPI); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if err := checkServerConfig(context.Background(), objAPI); err != nil {
|
if err := checkServerConfig(context.Background(), objAPI); err != nil {
|
||||||
if err == errConfigNotFound {
|
if err == errConfigNotFound {
|
||||||
|
@ -265,6 +265,12 @@ func serverMain(ctx *cli.Context) {
|
|||||||
globalActiveCred = config.Credential
|
globalActiveCred = config.Credential
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if os.IsNotExist(err) {
|
||||||
|
if _, err = Load(getConfigFile()+".deprecated", config); err == nil {
|
||||||
|
globalActiveCred = config.Credential
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if globalActiveCred.IsValid() {
|
if globalActiveCred.IsValid() {
|
||||||
// Credential is valid don't throw an error instead print a message regarding deprecation of 'config.json'
|
// Credential is valid don't throw an error instead print a message regarding deprecation of 'config.json'
|
||||||
// based model and proceed to use it for now in distributed setup.
|
// based model and proceed to use it for now in distributed setup.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user