Read env config for predictions

This commit is contained in:
Seth Vargo 2017-09-04 23:55:08 -04:00
parent 2a4404c20a
commit e3fff2a788
No known key found for this signature in database
GPG Key ID: C921994F9C27E0FF

View File

@ -21,7 +21,21 @@ func NewPredict() *Predict {
func (p *Predict) Client() *api.Client {
p.clientOnce.Do(func() {
if p.client == nil { // For tests
p.client, _ = api.NewClient(nil)
client, _ := api.NewClient(nil)
if client.Token() == "" {
helper, err := DefaultTokenHelper()
if err != nil {
return
}
token, err := helper.Get()
if err != nil {
return
}
client.SetToken(token)
}
p.client = client
}
})
return p.client