Merge branch 'master' into dependabot/go_modules/go.unistack.org/micro/v3-3.8.21

This commit is contained in:
Василий Толстов 2022-02-16 15:01:24 +03:00 committed by GitHub
commit cf6bde48ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 1 deletions

View File

@ -15,7 +15,7 @@ jobs:
steps:
- name: metadata
id: metadata
uses: dependabot/fetch-metadata@v1.1.1
uses: dependabot/fetch-metadata@v1.2.0
with:
github-token: "${{ secrets.TOKEN }}"
- name: approve

View File

@ -1,12 +1,19 @@
package vault
import (
"net/http"
"time"
"github.com/hashicorp/vault/api"
"go.unistack.org/micro/v3/config"
)
type httpClientKey struct{}
func HTTPClient(c *http.Client) config.Option {
return config.SetOption(httpClientKey{}, c)
}
type configKey struct{}
func Config(cfg *api.Config) config.Option {

View File

@ -4,6 +4,7 @@ import (
"context"
"encoding/json"
"fmt"
"net/http"
"time"
"github.com/hashicorp/vault/api"
@ -46,6 +47,10 @@ func (c *vaultConfig) Init(opts ...config.Option) error {
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 {
cfg.Timeout = v
}