command/connect/proxy: set ACL token based on proxy token flag
This commit is contained in:
parent
9435d8088c
commit
4100c9567f
|
@ -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,
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
|
|
@ -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())
|
||||
}
|
Loading…
Reference in New Issue