github.com/ezbercih/terraform@v0.1.1-0.20140729011846-3c33865e0839/builtin/providers/heroku/config.go (about) 1 package heroku 2 3 import ( 4 "log" 5 "os" 6 7 "github.com/bgentry/heroku-go" 8 ) 9 10 type Config struct { 11 APIKey string `mapstructure:"api_key"` 12 Email string `mapstructure:"email"` 13 } 14 15 // Client() returns a new client for accessing heroku. 16 // 17 func (c *Config) Client() (*heroku.Client, error) { 18 19 // If we have env vars set (like in the acc) tests, 20 // we need to override the values passed in here. 21 if v := os.Getenv("HEROKU_EMAIL"); v != "" { 22 c.Email = v 23 } 24 if v := os.Getenv("HEROKU_API_KEY"); v != "" { 25 c.APIKey = v 26 } 27 28 client := heroku.Client{Username: c.Email, Password: c.APIKey} 29 30 log.Printf("[INFO] Heroku Client configured for user: %s", c.Email) 31 32 return &client, nil 33 }