mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-03 03:58:01 +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{
|
Secrets: []*framework.Secret{
|
||||||
secretCreds(&b),
|
secretCreds(&b),
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Clean: func() {
|
||||||
|
b.ResetDB(nil)
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
return &b
|
return &b
|
||||||
|
|||||||
@@ -31,6 +31,8 @@ func Backend() *backend {
|
|||||||
Secrets: []*framework.Secret{
|
Secrets: []*framework.Secret{
|
||||||
secretCreds(&b),
|
secretCreds(&b),
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Clean: b.ResetDB,
|
||||||
}
|
}
|
||||||
|
|
||||||
return &b
|
return &b
|
||||||
|
|||||||
@@ -31,6 +31,8 @@ func Backend() *backend {
|
|||||||
Secrets: []*framework.Secret{
|
Secrets: []*framework.Secret{
|
||||||
secretCreds(&b),
|
secretCreds(&b),
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Clean: b.ResetDB,
|
||||||
}
|
}
|
||||||
|
|
||||||
return &b
|
return &b
|
||||||
|
|||||||
@@ -256,6 +256,12 @@ func (c *Core) unmount(path string) (bool, error) {
|
|||||||
return true, err
|
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
|
// Unmount the backend entirely
|
||||||
if err := c.router.Unmount(path); err != nil {
|
if err := c.router.Unmount(path); err != nil {
|
||||||
return true, err
|
return true, err
|
||||||
@@ -271,7 +277,7 @@ func (c *Core) unmount(path string) (bool, error) {
|
|||||||
return true, err
|
return true, err
|
||||||
}
|
}
|
||||||
if c.logger.IsInfo() {
|
if c.logger.IsInfo() {
|
||||||
c.logger.Info("core: successful unmounted", "path", path)
|
c.logger.Info("core: successfully unmounted", "path", path)
|
||||||
}
|
}
|
||||||
return true, nil
|
return true, nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user