Skip to content

Commit

Permalink
Addressed comments.
Browse files Browse the repository at this point in the history
Signed-off-by: bwplotka <[email protected]>
  • Loading branch information
bwplotka committed Jan 16, 2025
1 parent 072259e commit 6e6edac
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions config/http_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ var (
http2Enabled: true,
// 5 minutes is typically above the maximum sane scrape interval. So we can
// use keepalive for all configurations.
idleConnTimeout: 5 * time.Minute,
idleConnTimeout: 5 * time.Minute,
newTLSConfigFunc: NewTLSConfigWithContext,
}
)

Expand Down Expand Up @@ -452,8 +453,8 @@ func (a *BasicAuth) UnmarshalYAML(unmarshal func(interface{}) error) error {
// by net.Dialer.
type DialContextFunc func(context.Context, string, string) (net.Conn, error)

// NewTLSConfigFunc returns new tls.Config.
type NewTLSConfigFunc func() (*tls.Config, error)
// NewTLSConfigFunc returns tls.Config.
type NewTLSConfigFunc func(context.Context, *TLSConfig, ...TLSConfigOption) (*tls.Config, error)

type httpClientOptions struct {
dialContextFunc DialContextFunc
Expand Down Expand Up @@ -487,6 +488,7 @@ func WithDialContextFunc(fn DialContextFunc) HTTPClientOption {

// WithNewTLSConfigFunc allows you to override the func that creates the TLS config
// from the prometheus http config.
// The default is `NewTLSConfigWithContext`.
func WithNewTLSConfigFunc(newTLSConfigFunc NewTLSConfigFunc) HTTPClientOption {
return httpClientOptionFunc(func(opts *httpClientOptions) {
opts.newTLSConfigFunc = newTLSConfigFunc
Expand Down Expand Up @@ -683,15 +685,7 @@ func NewRoundTripperFromConfigWithContext(ctx context.Context, cfg HTTPClientCon
return rt, nil
}

if opts.newTLSConfigFunc != nil {
tlsConfig, err := opts.newTLSConfigFunc()
if err != nil {
return nil, err
}
return newRT(tlsConfig)
}

tlsConfig, err := NewTLSConfig(&cfg.TLSConfig, WithSecretManager(opts.secretManager))
tlsConfig, err := opts.tlsConfigFunc(ctx, &cfg.TLSConfig, WithSecretManager(opts.secretManager))

Check failure on line 688 in config/http_config.go

View workflow job for this annotation

GitHub Actions / lint

opts.tlsConfigFunc undefined (type httpClientOptions has no field or method tlsConfigFunc) (typecheck)

Check failure on line 688 in config/http_config.go

View workflow job for this annotation

GitHub Actions / lint

opts.tlsConfigFunc undefined (type httpClientOptions has no field or method tlsConfigFunc) (typecheck)
if err != nil {
return nil, err
}
Expand Down

0 comments on commit 6e6edac

Please sign in to comment.