mirror of
https://github.com/minio/minio.git
synced 2025-11-07 12:52:58 -05:00
Remove global custom config path variables, use get/set methods instead
This commit is contained in:
@@ -26,6 +26,9 @@ import (
|
||||
|
||||
// getDonutConfigPath get donut config file path
|
||||
func getDonutConfigPath() (string, error) {
|
||||
if customConfigPath != "" {
|
||||
return customConfigPath, nil
|
||||
}
|
||||
u, err := user.Current()
|
||||
if err != nil {
|
||||
return "", iodine.New(err, nil)
|
||||
@@ -34,20 +37,19 @@ func getDonutConfigPath() (string, error) {
|
||||
return donutConfigPath, nil
|
||||
}
|
||||
|
||||
// NOTE - this is not thread safe use it carefully, currently its purpose is only for testing purposes.
|
||||
var CustomConfigPath string
|
||||
// internal variable only accessed via get/set methods
|
||||
var customConfigPath string
|
||||
|
||||
// SetDonutConfigPath - set custom donut config path
|
||||
func SetDonutConfigPath(configPath string) {
|
||||
customConfigPath = configPath
|
||||
}
|
||||
|
||||
// SaveConfig save donut config
|
||||
func SaveConfig(a *Config) error {
|
||||
var donutConfigPath string
|
||||
var err error
|
||||
if CustomConfigPath != "" {
|
||||
donutConfigPath = CustomConfigPath
|
||||
} else {
|
||||
donutConfigPath, err = getDonutConfigPath()
|
||||
if err != nil {
|
||||
return iodine.New(err, nil)
|
||||
}
|
||||
donutConfigPath, err := getDonutConfigPath()
|
||||
if err != nil {
|
||||
return iodine.New(err, nil)
|
||||
}
|
||||
qc, err := quick.New(a)
|
||||
if err != nil {
|
||||
@@ -61,15 +63,9 @@ func SaveConfig(a *Config) error {
|
||||
|
||||
// LoadConfig load donut config
|
||||
func LoadConfig() (*Config, error) {
|
||||
var donutConfigPath string
|
||||
var err error
|
||||
if CustomConfigPath != "" {
|
||||
donutConfigPath = CustomConfigPath
|
||||
} else {
|
||||
donutConfigPath, err = getDonutConfigPath()
|
||||
if err != nil {
|
||||
return nil, iodine.New(err, nil)
|
||||
}
|
||||
donutConfigPath, err := getDonutConfigPath()
|
||||
if err != nil {
|
||||
return nil, iodine.New(err, nil)
|
||||
}
|
||||
a := &Config{}
|
||||
a.Version = "0.0.1"
|
||||
|
||||
@@ -66,7 +66,7 @@ func (s *MyDonutSuite) SetUpSuite(c *C) {
|
||||
conf.DonutName = "test"
|
||||
conf.NodeDiskMap = createTestNodeDiskMap(root)
|
||||
conf.MaxSize = 100000
|
||||
CustomConfigPath = filepath.Join(root, "donut.json")
|
||||
SetDonutConfigPath(filepath.Join(root, "donut.json"))
|
||||
err = SaveConfig(conf)
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ func (s *MyCacheSuite) SetUpSuite(c *C) {
|
||||
c.Assert(err, IsNil)
|
||||
s.root = root
|
||||
|
||||
CustomConfigPath = filepath.Join(root, "donut.json")
|
||||
SetDonutConfigPath(filepath.Join(root, "donut.json"))
|
||||
dc, err = New()
|
||||
c.Assert(err, IsNil)
|
||||
|
||||
|
||||
@@ -46,15 +46,6 @@ const (
|
||||
yyyymmdd = "20060102"
|
||||
)
|
||||
|
||||
var ignoredHeaders = map[string]bool{
|
||||
"Authorization": true,
|
||||
"Content-Type": true,
|
||||
"Accept-Encoding": true,
|
||||
"Content-Length": true,
|
||||
"User-Agent": true,
|
||||
"Connection": true,
|
||||
}
|
||||
|
||||
// sumHMAC calculate hmac between two input byte array
|
||||
func sumHMAC(key []byte, data []byte) []byte {
|
||||
hash := hmac.New(sha256.New, key)
|
||||
|
||||
Reference in New Issue
Block a user