2014-07-22 23:03:30 -05:00
|
|
|
package heroku
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
2014-08-27 17:50:38 -05:00
|
|
|
"net/http"
|
2014-07-22 23:03:30 -05:00
|
|
|
|
2014-08-27 09:50:37 -05:00
|
|
|
"github.com/cyberdelia/heroku-go/v3"
|
2014-07-22 23:03:30 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
type Config struct {
|
2014-11-19 07:25:18 -06:00
|
|
|
Email string
|
|
|
|
APIKey string
|
2014-07-22 23:03:30 -05:00
|
|
|
}
|
|
|
|
|
2014-08-27 09:50:37 -05:00
|
|
|
// Client() returns a new Service for accessing Heroku.
|
2014-07-22 23:03:30 -05:00
|
|
|
//
|
2014-08-27 09:50:37 -05:00
|
|
|
func (c *Config) Client() (*heroku.Service, error) {
|
2014-08-27 17:50:38 -05:00
|
|
|
service := heroku.NewService(&http.Client{
|
|
|
|
Transport: &heroku.Transport{
|
|
|
|
Username: c.Email,
|
|
|
|
Password: c.APIKey,
|
|
|
|
UserAgent: heroku.DefaultUserAgent,
|
|
|
|
},
|
|
|
|
})
|
2014-07-22 23:03:30 -05:00
|
|
|
|
|
|
|
log.Printf("[INFO] Heroku Client configured for user: %s", c.Email)
|
|
|
|
|
2014-08-27 17:50:38 -05:00
|
|
|
return service, nil
|
2014-07-22 23:03:30 -05:00
|
|
|
}
|