mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-02 19:47:54 +00:00
Add cleanup functions to multiple DB backends. (#2313)
Ensure it's called on unmount, not just for seal.
This commit is contained in:
@@ -30,6 +30,10 @@ func Backend() *backend {
|
||||
Secrets: []*framework.Secret{
|
||||
secretCreds(&b),
|
||||
},
|
||||
|
||||
Clean: func() {
|
||||
b.ResetDB(nil)
|
||||
},
|
||||
}
|
||||
|
||||
return &b
|
||||
|
||||
@@ -31,6 +31,8 @@ func Backend() *backend {
|
||||
Secrets: []*framework.Secret{
|
||||
secretCreds(&b),
|
||||
},
|
||||
|
||||
Clean: b.ResetDB,
|
||||
}
|
||||
|
||||
return &b
|
||||
|
||||
@@ -31,6 +31,8 @@ func Backend() *backend {
|
||||
Secrets: []*framework.Secret{
|
||||
secretCreds(&b),
|
||||
},
|
||||
|
||||
Clean: b.ResetDB,
|
||||
}
|
||||
|
||||
return &b
|
||||
|
||||
@@ -256,6 +256,12 @@ func (c *Core) unmount(path string) (bool, error) {
|
||||
return true, err
|
||||
}
|
||||
|
||||
// Call cleanup function if it exists
|
||||
b, ok := c.router.root.Get(path)
|
||||
if ok {
|
||||
b.(*routeEntry).backend.Cleanup()
|
||||
}
|
||||
|
||||
// Unmount the backend entirely
|
||||
if err := c.router.Unmount(path); err != nil {
|
||||
return true, err
|
||||
@@ -271,7 +277,7 @@ func (c *Core) unmount(path string) (bool, error) {
|
||||
return true, err
|
||||
}
|
||||
if c.logger.IsInfo() {
|
||||
c.logger.Info("core: successful unmounted", "path", path)
|
||||
c.logger.Info("core: successfully unmounted", "path", path)
|
||||
}
|
||||
return true, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user