mirror of
https://github.com/pomerium/pomerium.git
synced 2025-07-31 15:29:48 +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/option"
|
||||
|
||||
"github.com/pomerium/pomerium/internal/httputil"
|
||||
"github.com/pomerium/pomerium/internal/log"
|
||||
"github.com/pomerium/pomerium/pkg/grpc/directory"
|
||||
)
|
||||
|
@ -34,7 +33,6 @@ const (
|
|||
)
|
||||
|
||||
type config struct {
|
||||
httpClient *http.Client
|
||||
serviceAccount *ServiceAccount
|
||||
url string
|
||||
}
|
||||
|
@ -42,16 +40,6 @@ type config struct {
|
|||
// An Option changes the configuration for the Google directory provider.
|
||||
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.
|
||||
func WithServiceAccount(serviceAccount *ServiceAccount) Option {
|
||||
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)
|
||||
WithHTTPClient(http.DefaultClient)(cfg)
|
||||
WithURL(defaultProviderURL)(cfg)
|
||||
for _, option := range options {
|
||||
option(cfg)
|
||||
for _, opt := range opts {
|
||||
opt(cfg)
|
||||
}
|
||||
return cfg
|
||||
}
|
||||
|
@ -256,8 +243,7 @@ func (p *Provider) getAPIClient(ctx context.Context) (*admin.Service, error) {
|
|||
|
||||
p.apiClient, err = admin.NewService(ctx,
|
||||
option.WithTokenSource(ts),
|
||||
option.WithEndpoint(p.cfg.url),
|
||||
option.WithHTTPClient(p.cfg.httpClient))
|
||||
option.WithEndpoint(p.cfg.url))
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("google: failed creating admin service %w", err)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue