mirror of
https://github.com/optim-enterprises-bv/vault.git
synced 2025-11-02 03:27:54 +00:00
Add context to storage backends and wire it through a lot of places (#3817)
This commit is contained in:
committed by
Jeff Mitchell
parent
2864fbd697
commit
8142b42d95
@@ -1,6 +1,7 @@
|
||||
package file
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
@@ -14,7 +15,7 @@ import (
|
||||
"github.com/hashicorp/vault/logical"
|
||||
)
|
||||
|
||||
func Factory(conf *audit.BackendConfig) (audit.Backend, error) {
|
||||
func Factory(ctx context.Context, conf *audit.BackendConfig) (audit.Backend, error) {
|
||||
if conf.SaltConfig == nil {
|
||||
return nil, fmt.Errorf("nil salt config")
|
||||
}
|
||||
@@ -168,7 +169,12 @@ func (b *Backend) GetHash(data string) (string, error) {
|
||||
return audit.HashString(salt, data), nil
|
||||
}
|
||||
|
||||
func (b *Backend) LogRequest(auth *logical.Auth, req *logical.Request, outerErr error) error {
|
||||
func (b *Backend) LogRequest(
|
||||
_ context.Context,
|
||||
auth *logical.Auth,
|
||||
req *logical.Request,
|
||||
outerErr error) error {
|
||||
|
||||
b.fileLock.Lock()
|
||||
defer b.fileLock.Unlock()
|
||||
|
||||
@@ -199,6 +205,7 @@ func (b *Backend) LogRequest(auth *logical.Auth, req *logical.Request, outerErr
|
||||
}
|
||||
|
||||
func (b *Backend) LogResponse(
|
||||
_ context.Context,
|
||||
auth *logical.Auth,
|
||||
req *logical.Request,
|
||||
resp *logical.Response,
|
||||
@@ -264,7 +271,7 @@ func (b *Backend) open() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (b *Backend) Reload() error {
|
||||
func (b *Backend) Reload(_ context.Context) error {
|
||||
switch b.path {
|
||||
case "stdout", "discard":
|
||||
return nil
|
||||
@@ -288,7 +295,7 @@ func (b *Backend) Reload() error {
|
||||
return b.open()
|
||||
}
|
||||
|
||||
func (b *Backend) Invalidate() {
|
||||
func (b *Backend) Invalidate(_ context.Context) {
|
||||
b.saltMutex.Lock()
|
||||
defer b.saltMutex.Unlock()
|
||||
b.salt = nil
|
||||
|
||||
Reference in New Issue
Block a user