mirror of
https://github.com/pomerium/pomerium.git
synced 2025-08-06 02:09:15 +02:00
google: remove WithHTTPClient (#2391)
This commit is contained in:
parent
ac8ae3ef5b
commit
8f7357b333
1 changed files with 4 additions and 18 deletions
|
@ -17,7 +17,6 @@ import (
|
||||||
"google.golang.org/api/googleapi"
|
"google.golang.org/api/googleapi"
|
||||||
"google.golang.org/api/option"
|
"google.golang.org/api/option"
|
||||||
|
|
||||||
"github.com/pomerium/pomerium/internal/httputil"
|
|
||||||
"github.com/pomerium/pomerium/internal/log"
|
"github.com/pomerium/pomerium/internal/log"
|
||||||
"github.com/pomerium/pomerium/pkg/grpc/directory"
|
"github.com/pomerium/pomerium/pkg/grpc/directory"
|
||||||
)
|
)
|
||||||
|
@ -34,7 +33,6 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
type config struct {
|
type config struct {
|
||||||
httpClient *http.Client
|
|
||||||
serviceAccount *ServiceAccount
|
serviceAccount *ServiceAccount
|
||||||
url string
|
url string
|
||||||
}
|
}
|
||||||
|
@ -42,16 +40,6 @@ type config struct {
|
||||||
// An Option changes the configuration for the Google directory provider.
|
// An Option changes the configuration for the Google directory provider.
|
||||||
type Option func(cfg *config)
|
type Option func(cfg *config)
|
||||||
|
|
||||||
// WithHTTPClient sets the http client option.
|
|
||||||
func WithHTTPClient(httpClient *http.Client) Option {
|
|
||||||
return func(cfg *config) {
|
|
||||||
cfg.httpClient = httputil.NewLoggingClient(httpClient,
|
|
||||||
func(evt *zerolog.Event) *zerolog.Event {
|
|
||||||
return evt.Str("provider", "google")
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// WithServiceAccount sets the service account in the Google configuration.
|
// WithServiceAccount sets the service account in the Google configuration.
|
||||||
func WithServiceAccount(serviceAccount *ServiceAccount) Option {
|
func WithServiceAccount(serviceAccount *ServiceAccount) Option {
|
||||||
return func(cfg *config) {
|
return func(cfg *config) {
|
||||||
|
@ -66,12 +54,11 @@ func WithURL(url string) Option {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getConfig(options ...Option) *config {
|
func getConfig(opts ...Option) *config {
|
||||||
cfg := new(config)
|
cfg := new(config)
|
||||||
WithHTTPClient(http.DefaultClient)(cfg)
|
|
||||||
WithURL(defaultProviderURL)(cfg)
|
WithURL(defaultProviderURL)(cfg)
|
||||||
for _, option := range options {
|
for _, opt := range opts {
|
||||||
option(cfg)
|
opt(cfg)
|
||||||
}
|
}
|
||||||
return cfg
|
return cfg
|
||||||
}
|
}
|
||||||
|
@ -256,8 +243,7 @@ func (p *Provider) getAPIClient(ctx context.Context) (*admin.Service, error) {
|
||||||
|
|
||||||
p.apiClient, err = admin.NewService(ctx,
|
p.apiClient, err = admin.NewService(ctx,
|
||||||
option.WithTokenSource(ts),
|
option.WithTokenSource(ts),
|
||||||
option.WithEndpoint(p.cfg.url),
|
option.WithEndpoint(p.cfg.url))
|
||||||
option.WithHTTPClient(p.cfg.httpClient))
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("google: failed creating admin service %w", err)
|
return nil, fmt.Errorf("google: failed creating admin service %w", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue