mirror of
https://github.com/hashicorp/vault.git
synced 2025-11-28 14:11:10 +01:00
Add check to ensure we don't overwrite existing connections
This commit is contained in:
parent
f92d6868a0
commit
2e2d3827da
@ -78,12 +78,17 @@ func (b *databaseBackend) getDBObj(name string) (dbplugin.Database, bool) {
|
|||||||
// caches it in the connections map. The caller of this function needs to hold
|
// caches it in the connections map. The caller of this function needs to hold
|
||||||
// the backend's write lock
|
// the backend's write lock
|
||||||
func (b *databaseBackend) createDBObj(s logical.Storage, name string) (dbplugin.Database, error) {
|
func (b *databaseBackend) createDBObj(s logical.Storage, name string) (dbplugin.Database, error) {
|
||||||
|
db, ok := b.connections[name]
|
||||||
|
if ok {
|
||||||
|
return db, nil
|
||||||
|
}
|
||||||
|
|
||||||
config, err := b.DatabaseConfig(s, name)
|
config, err := b.DatabaseConfig(s, name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
db, err := dbplugin.PluginFactory(config.PluginName, b.System(), b.logger)
|
db, err = dbplugin.PluginFactory(config.PluginName, b.System(), b.logger)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user