func parseConfig() { configPath := ConfigFilePath() var err os.Error if config, err = jsonconfig.ReadFile(configPath); err != nil { log.Fatal(err.String()) return } }
func Load(configPath string) (*Config, os.Error) { obj, err := jsonconfig.ReadFile(configPath) if err != nil { return nil, err } conf := &Config{ Obj: obj, configPath: configPath, } return conf, nil }
// Reads google storage config and creates a Client. Exits on error. func doConfig(t *testing.T) (gsa *Client, bucket string) { cf, err := jsonconfig.ReadFile("testconfig.json") if err != nil { t.Fatalf("Failed to read config: %v", err) } var config jsonconfig.Obj config = cf.RequiredObject("gsconf") if err := cf.Validate(); err != nil { t.Fatalf("Invalid config: %v", err) } auth := config.RequiredObject("auth") bucket = config.RequiredString("bucket") if err := config.Validate(); err != nil { t.Fatalf("Invalid config: %v", err) } gsa = NewClient(&oauth.Transport{ &oauth.Config{ ClientId: auth.RequiredString("client_id"), ClientSecret: auth.RequiredString("client_secret"), Scope: "https://www.googleapis.com/auth/devstorage.read_write", AuthURL: "https://accounts.google.com/o/oauth2/auth", TokenURL: "https://accounts.google.com/o/oauth2/token", RedirectURL: "urn:ietf:wg:oauth:2.0:oob", }, &oauth.Token{ AccessToken: "", RefreshToken: auth.RequiredString("refresh_token"), TokenExpiry: 0, }, nil, }) if err := auth.Validate(); err != nil { t.Fatalf("Invalid config: %v", err) } return }