-
Notifications
You must be signed in to change notification settings - Fork 1
/
client.go
39 lines (32 loc) · 923 Bytes
/
client.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package vault
import (
"github.com/alexfalkowski/go-service/transport/http"
"github.com/alexfalkowski/go-service/transport/http/metrics/prometheus"
"github.com/alexfalkowski/go-service/transport/http/trace/opentracing"
"github.com/hashicorp/vault/api"
"go.uber.org/fx"
"go.uber.org/zap"
)
// ConfigParams for vault.
type ConfigParams struct {
fx.In
Config *http.Config
Logger *zap.Logger
Tracer opentracing.Tracer
Metrics *prometheus.ClientMetrics
}
// NewConfig for vault.
func NewConfig(params ConfigParams) *api.Config {
client := http.NewClient(
http.ClientParams{Config: params.Config},
http.WithClientLogger(params.Logger), http.WithClientTracer(params.Tracer),
http.WithClientMetrics(params.Metrics),
)
config := api.DefaultConfig()
config.HttpClient = client
return config
}
// NewClient for vault.
func NewClient(cfg *api.Config) (*api.Client, error) {
return api.NewClient(cfg)
}