From 16a7ecf55aadead420aac30e8e517ffc32f095b8 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Sat, 26 Jan 2013 16:46:19 -0800 Subject: [PATCH] client: tolerate missing config file Change-Id: I43fd2439b3eddb3d883d0db6cc6f23fe535aeb28 --- pkg/client/config.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/client/config.go b/pkg/client/config.go index c07777ae5..e69cbf2d3 100644 --- a/pkg/client/config.go +++ b/pkg/client/config.go @@ -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) }