Hold onto the token store from the base deps in the Client (#10432) (#10433)

This is needed in order to access the agent token in some enterprise code.
This commit is contained in:
Matt Keeler 2021-06-18 17:07:06 -04:00 committed by GitHub
parent 2868a14451
commit 3609d903af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 0 deletions

3
.changelog/10432.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:bug
license: **(Enterprise only)** Fixed an issue that would cause client agents on versions before 1.10 to not be able to retrieve the license from a 1.10+ server.
```

View File

@ -12,6 +12,7 @@ import (
"github.com/hashicorp/consul/agent/pool"
"github.com/hashicorp/consul/agent/router"
"github.com/hashicorp/consul/agent/structs"
"github.com/hashicorp/consul/agent/token"
"github.com/hashicorp/consul/lib"
"github.com/hashicorp/consul/logging"
"github.com/hashicorp/consul/tlsutil"
@ -87,6 +88,9 @@ type Client struct {
EnterpriseClient
tlsConfigurator *tlsutil.Configurator
// tokens is the agent wide token store
tokens *token.Store
}
// NewClient creates and returns a Client
@ -131,6 +135,7 @@ func NewClient(config *Config, options ...ConsulOption) (*Client, error) {
logger: logger,
shutdownCh: make(chan struct{}),
tlsConfigurator: tlsConfigurator,
tokens: flat.tokens,
}
c.rpcLimiter.Store(rate.NewLimiter(config.RPCRate, config.RPCMaxBurst))