provide timeout option and lower default

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2021-03-10 01:04:58 +03:00
parent 68696aebd5
commit 16cde1bfae
2 changed files with 14 additions and 0 deletions

View File

@@ -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
}