provide timeout option and lower default
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
6
vault.go
6
vault.go
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/vault/api"
|
||||
"github.com/imdario/mergo"
|
||||
@@ -36,6 +37,7 @@ func (c *vaultConfig) Init(opts ...config.Option) error {
|
||||
}
|
||||
|
||||
cfg := api.DefaultConfig()
|
||||
cfg.Timeout = 3 * time.Second
|
||||
path := ""
|
||||
token := ""
|
||||
roleID := ""
|
||||
@@ -46,6 +48,10 @@ func (c *vaultConfig) Init(opts ...config.Option) error {
|
||||
cfg = v
|
||||
}
|
||||
|
||||
if v, ok := c.opts.Context.Value(timeoutKey{}).(time.Duration); ok {
|
||||
cfg.Timeout = v
|
||||
}
|
||||
|
||||
if v, ok := c.opts.Context.Value(addrKey{}).(string); ok {
|
||||
cfg.Address = v
|
||||
}
|
||||
|
Reference in New Issue
Block a user