Merge pull request #1612 from harshavardhana/config-folder

config: Config folder option should be honored.
This commit is contained in:
Harshavardhana
2016-02-17 16:04:21 -08:00
3 changed files with 18 additions and 10 deletions
+8 -10
View File
@@ -29,9 +29,6 @@ import (
// mcCustomConfigDir contains the whole path to config dir. Only access via get/set functions.
var mcCustomConfigDir string
// mcCustomConfigPath contains the whole path to config file. Only access via get/set functions.
var mcCustomConfigPath string
// setMcConfigDir - set a custom minio client config folder.
func setMcConfigDir(configDir string) {
mcCustomConfigDir = configDir
@@ -46,13 +43,14 @@ func getMcConfigDir() (string, *probe.Error) {
if e != nil {
return "", probe.NewError(e)
}
var configDir string
// For windows the path is slightly different
switch runtime.GOOS {
case "windows":
return filepath.Join(homeDir, globalMCConfigWindowsDir), nil
default:
return filepath.Join(homeDir, globalMCConfigDir), nil
if runtime.GOOS == "windows" {
configDir = filepath.Join(homeDir, globalMCConfigWindowsDir)
} else {
configDir = filepath.Join(homeDir, globalMCConfigDir)
}
return configDir, nil
}
// mustGetMcConfigDir - construct minio client config folder or fail
@@ -77,8 +75,8 @@ func createMcConfigDir() *probe.Error {
// getMcConfigPath - construct minio client configuration path
func getMcConfigPath() (string, *probe.Error) {
if mcCustomConfigPath != "" {
return mcCustomConfigPath, nil
if mcCustomConfigDir != "" {
return filepath.Join(mcCustomConfigDir, globalMCConfigFile), nil
}
dir, err := getMcConfigDir()
if err != nil {
+2
View File
@@ -78,6 +78,8 @@ func commandNotFound(ctx *cli.Context, command string) {
// Check for sane config environment early on and gracefully report.
func checkConfig() {
// Refresh the config once.
loadMcConfig = loadMcConfigFactory()
// Ensures config file is sane.
_, err := loadMcConfig()
fatalIf(err.Trace(mustGetMcConfigPath()), "Unable to access configuration file.")
+8
View File
@@ -36,6 +36,14 @@ type RoundTripTrace struct {
Transport http.RoundTripper // HTTP transport that needs to be intercepted
}
// CancelRequest implements functinality to cancel an underlying request.
func (t RoundTripTrace) CancelRequest(req *http.Request) {
transport, ok := t.Transport.(*http.Transport)
if ok {
transport.CancelRequest(req)
}
}
// RoundTrip executes user provided request and response hooks for each HTTP call.
func (t RoundTripTrace) RoundTrip(req *http.Request) (res *http.Response, err error) {
timeStamp := time.Now()