Skip to content

Commit

Permalink
Merge pull request #1 from tomelliot16/add-listener-config-for-metrics
Browse files Browse the repository at this point in the history
Add ListenerConfig for metrics
  • Loading branch information
tomelliot16 committed Sep 27, 2023
2 parents c93e2ab + 76e321a commit 00dad56
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/metrics/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ type Options struct {
// TLSOpts is used to allow configuring the TLS config used for the server.
// This also allows providing a certificate via GetCertificate.
TLSOpts []func(*tls.Config)

// ListenConfig contains options for listening to an address on the metric server.
// Note: This does not work with SecureServing=true
ListenConfig net.ListenConfig
}

// Filter is a func that is added around metrics and extra handlers on the metrics server.
Expand Down Expand Up @@ -249,7 +253,7 @@ func (s *defaultServer) Start(ctx context.Context) error {

func (s *defaultServer) createListener(ctx context.Context, log logr.Logger) (net.Listener, error) {
if !s.options.SecureServing {
return net.Listen("tcp", s.options.BindAddress)
return s.options.ListenConfig.Listen(context.Background(), "tcp", s.options.BindAddress)
}

cfg := &tls.Config{ //nolint:gosec
Expand Down

0 comments on commit 00dad56

Please sign in to comment.