Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
16cde1bfae | |||
|
68696aebd5 | ||
|
8d46e8b45a |
2
go.mod
2
go.mod
@@ -7,7 +7,7 @@ require (
|
||||
github.com/hashicorp/go-rootcerts v1.0.2 // indirect
|
||||
github.com/hashicorp/vault/api v1.0.4
|
||||
github.com/imdario/mergo v0.3.11
|
||||
github.com/unistack-org/micro/v3 v3.2.16
|
||||
github.com/unistack-org/micro/v3 v3.2.20
|
||||
golang.org/x/time v0.0.0-20190921001708-c4c64cad1fd0 // indirect
|
||||
gopkg.in/square/go-jose.v2 v2.4.1 // indirect
|
||||
)
|
||||
|
3
go.sum
3
go.sum
@@ -85,6 +85,9 @@ github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/unistack-org/micro/v3 v3.2.16 h1:eQwEJr7RiB0jvOSAil+c6t2C1zW7MpfFAVx2u9PmItM=
|
||||
github.com/unistack-org/micro/v3 v3.2.16/go.mod h1:y+fV+BPNK2IqGoLquRU396jTYifG0HCw3zxFfI4E0dc=
|
||||
github.com/unistack-org/micro/v3 v3.2.17 h1:WNkkcKj1NMLViH9YgSDJRA2PJxIaDmY3GQBjHQV20DU=
|
||||
github.com/unistack-org/micro/v3 v3.2.17/go.mod h1:y+fV+BPNK2IqGoLquRU396jTYifG0HCw3zxFfI4E0dc=
|
||||
github.com/unistack-org/micro/v3 v3.2.20/go.mod h1:y+fV+BPNK2IqGoLquRU396jTYifG0HCw3zxFfI4E0dc=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
|
@@ -1,6 +1,8 @@
|
||||
package vault
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/vault/api"
|
||||
"github.com/unistack-org/micro/v3/config"
|
||||
)
|
||||
@@ -40,3 +42,9 @@ type secretIDKey struct{}
|
||||
func SecretID(secret string) config.Option {
|
||||
return config.SetOption(secretIDKey{}, secret)
|
||||
}
|
||||
|
||||
type timeoutKey struct{}
|
||||
|
||||
func Timeout(td time.Duration) config.Option {
|
||||
return config.SetOption(timeoutKey{}, td)
|
||||
}
|
||||
|
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