Merge branch 'master' into dependabot/go_modules/go.unistack.org/micro/v3-3.8.21
This commit is contained in:
commit
cf6bde48ae
2
.github/workflows/dependabot-automerge.yml
vendored
2
.github/workflows/dependabot-automerge.yml
vendored
@ -15,7 +15,7 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- name: metadata
|
- name: metadata
|
||||||
id: metadata
|
id: metadata
|
||||||
uses: dependabot/fetch-metadata@v1.1.1
|
uses: dependabot/fetch-metadata@v1.2.0
|
||||||
with:
|
with:
|
||||||
github-token: "${{ secrets.TOKEN }}"
|
github-token: "${{ secrets.TOKEN }}"
|
||||||
- name: approve
|
- name: approve
|
||||||
|
@ -1,12 +1,19 @@
|
|||||||
package vault
|
package vault
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/hashicorp/vault/api"
|
"github.com/hashicorp/vault/api"
|
||||||
"go.unistack.org/micro/v3/config"
|
"go.unistack.org/micro/v3/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type httpClientKey struct{}
|
||||||
|
|
||||||
|
func HTTPClient(c *http.Client) config.Option {
|
||||||
|
return config.SetOption(httpClientKey{}, c)
|
||||||
|
}
|
||||||
|
|
||||||
type configKey struct{}
|
type configKey struct{}
|
||||||
|
|
||||||
func Config(cfg *api.Config) config.Option {
|
func Config(cfg *api.Config) config.Option {
|
||||||
|
5
vault.go
5
vault.go
@ -4,6 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/hashicorp/vault/api"
|
"github.com/hashicorp/vault/api"
|
||||||
@ -46,6 +47,10 @@ func (c *vaultConfig) Init(opts ...config.Option) error {
|
|||||||
cfg = v
|
cfg = v
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if v, ok := c.opts.Context.Value(httpClientKey{}).(*http.Client); ok {
|
||||||
|
cfg.HttpClient = v
|
||||||
|
}
|
||||||
|
|
||||||
if v, ok := c.opts.Context.Value(timeoutKey{}).(time.Duration); ok {
|
if v, ok := c.opts.Context.Value(timeoutKey{}).(time.Duration); ok {
|
||||||
cfg.Timeout = v
|
cfg.Timeout = v
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user