mirror of
https://github.com/minio/minio.git
synced 2025-12-02 06:07:51 -05:00
Remove global custom config path variables, use get/set methods instead
This commit is contained in:
@@ -39,6 +39,9 @@ type Config struct {
|
||||
|
||||
// getAuthConfigPath get donut config file path
|
||||
func getAuthConfigPath() (string, error) {
|
||||
if customConfigPath != "" {
|
||||
return customConfigPath, nil
|
||||
}
|
||||
u, err := user.Current()
|
||||
if err != nil {
|
||||
return "", iodine.New(err, nil)
|
||||
@@ -47,20 +50,19 @@ func getAuthConfigPath() (string, error) {
|
||||
return authConfigPath, nil
|
||||
}
|
||||
|
||||
// NOTE - this is not thread safe use it carefully, currently its purpose is only for testing purposes.
|
||||
var CustomConfigPath string
|
||||
// customConfigPath not accessed from outside only allowed through get/set methods
|
||||
var customConfigPath string
|
||||
|
||||
// SetAuthConfigPath - set custom auth config path
|
||||
func SetAuthConfigPath(configPath string) {
|
||||
customConfigPath = configPath
|
||||
}
|
||||
|
||||
// SaveConfig save donut config
|
||||
func SaveConfig(a *Config) error {
|
||||
var authConfigPath string
|
||||
var err error
|
||||
if CustomConfigPath != "" {
|
||||
authConfigPath = CustomConfigPath
|
||||
} else {
|
||||
authConfigPath, err = getAuthConfigPath()
|
||||
if err != nil {
|
||||
return iodine.New(err, nil)
|
||||
}
|
||||
authConfigPath, err := getAuthConfigPath()
|
||||
if err != nil {
|
||||
return iodine.New(err, nil)
|
||||
}
|
||||
qc, err := quick.New(a)
|
||||
if err != nil {
|
||||
@@ -74,15 +76,9 @@ func SaveConfig(a *Config) error {
|
||||
|
||||
// LoadConfig load donut config
|
||||
func LoadConfig() (*Config, error) {
|
||||
var authConfigPath string
|
||||
var err error
|
||||
if CustomConfigPath != "" {
|
||||
authConfigPath = CustomConfigPath
|
||||
} else {
|
||||
authConfigPath, err = getAuthConfigPath()
|
||||
if err != nil {
|
||||
return nil, iodine.New(err, nil)
|
||||
}
|
||||
authConfigPath, err := getAuthConfigPath()
|
||||
if err != nil {
|
||||
return nil, iodine.New(err, nil)
|
||||
}
|
||||
a := &Config{}
|
||||
a.Version = "0.0.1"
|
||||
|
||||
Reference in New Issue
Block a user