command/connect/proxy: set ACL token based on proxy token flag

This commit is contained in:
Mitchell Hashimoto 2018-05-06 20:27:31 -07:00
parent 9435d8088c
commit 4100c9567f
No known key found for this signature in database
GPG Key ID: 744E147AA52F5B0A
3 changed files with 23 additions and 0 deletions

View File

@ -80,6 +80,10 @@ func (c *cmd) Run(args []string) int {
if c.proxyID == "" {
c.proxyID = os.Getenv(proxyAgent.EnvProxyId)
}
if c.http.Token() == "" {
c.http.SetToken(os.Getenv(proxyAgent.EnvProxyToken))
}
// Setup the log outputs
logConfig := &logger.Config{
LogLevel: c.logLevel,

View File

@ -84,6 +84,10 @@ func (f *HTTPFlags) Token() string {
return f.token.String()
}
func (f *HTTPFlags) SetToken(v string) error {
return f.token.Set(v)
}
func (f *HTTPFlags) APIClient() (*api.Client, error) {
c := api.DefaultConfig()

View File

@ -0,0 +1,15 @@
package flags
import (
"testing"
"github.com/stretchr/testify/require"
)
func TestHTTPFlagsSetToken(t *testing.T) {
var f HTTPFlags
require := require.New(t)
require.Empty(f.Token())
require.NoError(f.SetToken("foo"))
require.Equal("foo", f.Token())
}