libnet/datastore: stop sharing defaultScopes singleton
Each call to datastore.DefaultScopes() would modify and return the same map. Consequently, some of the config for every NetworkController in the process would be mutated each time one is constructed or reconfigured. This behaviour is unexpected, unintended, and undesirable. Stop accidentally sharing configuration by changing DefaultScopes() to return a distinct map on each call. Signed-off-by: Cory Snider <csnider@mirantis.com>
This commit is contained in:
parent
8404507b9b
commit
8a20564847
1 changed files with 3 additions and 4 deletions
|
@ -154,13 +154,12 @@ var rootChain = defaultRootChain
|
|||
|
||||
// DefaultScopes returns a map of default scopes and its config for clients to use.
|
||||
func DefaultScopes(dataDir string) map[string]*ScopeCfg {
|
||||
s := makeDefaultScopes()
|
||||
if dataDir != "" {
|
||||
defaultScopes[LocalScope].Client.Address = dataDir + "/network/files/local-kv.db"
|
||||
return defaultScopes
|
||||
s[LocalScope].Client.Address = dataDir + "/network/files/local-kv.db"
|
||||
}
|
||||
|
||||
defaultScopes[LocalScope].Client.Address = defaultPrefix + "/local-kv.db"
|
||||
return defaultScopes
|
||||
return s
|
||||
}
|
||||
|
||||
// IsValid checks if the scope config has valid configuration.
|
||||
|
|
Loading…
Add table
Reference in a new issue