client: tolerate missing config file

Change-Id: I43fd2439b3eddb3d883d0db6cc6f23fe535aeb28
This commit is contained in:
Brad Fitzpatrick 2013-01-26 16:46:19 -08:00
parent ec8f01c467
commit 16a7ecf55a
1 changed files with 6 additions and 1 deletions

View File

@ -57,9 +57,14 @@ func ConfigFilePath() string {
var configOnce sync.Once
var config = make(map[string]interface{})
var parseConfigErr error
func parseConfig() {
configPath := ConfigFilePath()
if _, err := os.Stat(configPath); os.IsNotExist(err) {
parseConfigErr = os.ErrNotExist
return
}
var err error
if config, err = jsonconfig.ReadFile(configPath); err != nil {
@ -98,7 +103,6 @@ func serverOrDie() string {
}
func (c *Client) SetupAuth() error {
configOnce.Do(parseConfig)
if flagServer != nil && *flagServer != "" {
// If using an explicit blobserver, don't use auth
// configured from the config file, so we don't send
@ -110,6 +114,7 @@ func (c *Client) SetupAuth() error {
}
return err
}
configOnce.Do(parseConfig)
return c.SetupAuthFromConfig(config)
}