mirror of
https://github.com/status-im/consul.git
synced 2025-02-18 00:27:04 +00:00
agent: clone partial consul config
The agent configuration for the consul server is a partial configuration which needs to be cloned to avoid data races. This is a stop-gap measure before moving the configuration into a separate package.
This commit is contained in:
parent
727b6444ad
commit
7f7c0ad65e
@ -551,8 +551,13 @@ func (a *Agent) reloadWatches(cfg *Config) error {
|
|||||||
func (a *Agent) consulConfig() (*consul.Config, error) {
|
func (a *Agent) consulConfig() (*consul.Config, error) {
|
||||||
// Start with the provided config or default config
|
// Start with the provided config or default config
|
||||||
base := consul.DefaultConfig()
|
base := consul.DefaultConfig()
|
||||||
|
|
||||||
|
// a.config.ConsulConfig, if set, is a partial configuration for the
|
||||||
|
// consul server or client. Therefore, clone and augment it but
|
||||||
|
// don't use it as base directly.
|
||||||
if a.config.ConsulConfig != nil {
|
if a.config.ConsulConfig != nil {
|
||||||
base = a.config.ConsulConfig
|
base = new(consul.Config)
|
||||||
|
*base = *a.config.ConsulConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is set when the agent starts up
|
// This is set when the agent starts up
|
||||||
|
Loading…
x
Reference in New Issue
Block a user