command/meta: add token to client if we have it
This commit is contained in:
parent
df4dc88176
commit
b2e46896f6
|
@ -87,6 +87,9 @@ func (c *AuthCommand) Run(args []string) int {
|
|||
return 1
|
||||
}
|
||||
|
||||
c.Ui.Output(fmt.Sprintf(
|
||||
"Successfully authenticated!"))
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
|
|
|
@ -77,7 +77,26 @@ func (m *Meta) Client() (*api.Client, error) {
|
|||
config.HttpClient = &client
|
||||
}
|
||||
|
||||
return api.NewClient(config)
|
||||
// Build the client
|
||||
client, err := api.NewClient(config)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// If we have a token, then set that
|
||||
tokenHelper, err := m.TokenHelper()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
token, err := tokenHelper.Get()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if token != "" {
|
||||
client.SetToken(token)
|
||||
}
|
||||
|
||||
return client, nil
|
||||
}
|
||||
|
||||
// Config loads the configuration and returns it. If the configuration
|
||||
|
|
Loading…
Reference in New Issue