From e3fff2a78856cb0c5e2b14399dbe7fbc45aff200 Mon Sep 17 00:00:00 2001 From: Seth Vargo Date: Mon, 4 Sep 2017 23:55:08 -0400 Subject: [PATCH] Read env config for predictions --- command/base_predict.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/command/base_predict.go b/command/base_predict.go index 3b59147bb7..9312ac163d 100644 --- a/command/base_predict.go +++ b/command/base_predict.go @@ -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