mirror of https://github.com/minio/minio.git
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"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path"
|
||||
"runtime"
|
||||
"time"
|
||||
|
@ -227,6 +228,8 @@ func NewConfigSys() *ConfigSys {
|
|||
|
||||
// Migrates ${HOME}/.minio/config.json to '<export_path>/.minio.sys/config/config.json'
|
||||
func migrateConfigToMinioSys(objAPI ObjectLayer) error {
|
||||
defer os.Rename(getConfigFile(), getConfigFile()+".deprecated")
|
||||
|
||||
// Verify if backend already has the file.
|
||||
if err := checkServerConfig(context.Background(), objAPI); err != errConfigNotFound {
|
||||
return err
|
||||
|
@ -234,8 +237,14 @@ func migrateConfigToMinioSys(objAPI ObjectLayer) error {
|
|||
|
||||
var config = &serverConfig{}
|
||||
if _, err := Load(getConfigFile(), config); err != nil {
|
||||
if !os.IsNotExist(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)
|
||||
}
|
||||
|
@ -258,13 +267,13 @@ func initConfig(objAPI ObjectLayer) error {
|
|||
if err := migrateConfig(); err != nil {
|
||||
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 {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if err := checkServerConfig(context.Background(), objAPI); err != nil {
|
||||
if err == errConfigNotFound {
|
||||
|
|
|
@ -265,6 +265,12 @@ func serverMain(ctx *cli.Context) {
|
|||
globalActiveCred = config.Credential
|
||||
}
|
||||
|
||||
if os.IsNotExist(err) {
|
||||
if _, err = Load(getConfigFile()+".deprecated", config); err == nil {
|
||||
globalActiveCred = config.Credential
|
||||
}
|
||||
}
|
||||
|
||||
if globalActiveCred.IsValid() {
|
||||
// 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.
|
||||
|
|
Loading…
Reference in New Issue