Procházet zdrojové kódy

Apply suggestions from code review

Mariano Cano před 10 měsíci
rodič
revize
da56c70773
2 změnil soubory, kde provedl 8 přidání a 8 odebrání
  1. 6 6
      ca/client.go
  2. 2 2
      ca/tls.go

+ 6 - 6
ca/client.go

@@ -153,7 +153,7 @@ type RetryFunc func(code int) bool
 // ClientOption is the type of options passed to the Client constructor.
 // ClientOption is the type of options passed to the Client constructor.
 type ClientOption func(o *clientOptions) error
 type ClientOption func(o *clientOptions) error
 
 
-// TransportDecorator is the type used to allows customization of the HTTP
+// TransportDecorator is the type used to support customization of the HTTP
 // transport.
 // transport.
 type TransportDecorator func(http.RoundTripper) http.RoundTripper
 type TransportDecorator func(http.RoundTripper) http.RoundTripper
 
 
@@ -278,7 +278,7 @@ func (o *clientOptions) getTransport(endpoint string) (tr http.RoundTripper, err
 	}
 	}
 
 
 	// Wrap the transport using the decorator function if necessary
 	// Wrap the transport using the decorator function if necessary
-	return getTransportWithDecorator(tr, o.transportDecorator), nil
+	return decorateTransport(tr, o.transportDecorator), nil
 }
 }
 
 
 // WithTransport adds a custom transport to the Client. It will fail if a
 // WithTransport adds a custom transport to the Client. It will fail if a
@@ -293,9 +293,9 @@ func WithTransport(tr http.RoundTripper) ClientOption {
 	}
 	}
 }
 }
 
 
-// WithTransportDecorator allows customization of the HTTP transport used by the client.
-// The provided function receives the configured http.RoundTripper and can wrap it
-// with additional functionality.
+// WithTransportDecorator allows customization of the HTTP transport used by the
+// client. The provided function receives the configured [http.RoundTripper] and
+// can wrap it with additional functionality.
 func WithTransportDecorator(fn TransportDecorator) ClientOption {
 func WithTransportDecorator(fn TransportDecorator) ClientOption {
 	return func(o *clientOptions) error {
 	return func(o *clientOptions) error {
 		o.transportDecorator = fn
 		o.transportDecorator = fn
@@ -1602,7 +1602,7 @@ func clientError(err error) error {
 	return fmt.Errorf("client request failed: %w", err)
 	return fmt.Errorf("client request failed: %w", err)
 }
 }
 
 
-func getTransportWithDecorator(tr http.RoundTripper, td TransportDecorator) http.RoundTripper {
+func decorateTransport(tr http.RoundTripper, td TransportDecorator) http.RoundTripper {
 	if td != nil {
 	if td != nil {
 		return td(tr)
 		return td(tr)
 	}
 	}

+ 2 - 2
ca/tls.go

@@ -135,7 +135,7 @@ func (c *Client) getClientTLSConfig(ctx context.Context, sign *api.SignResponse,
 	tr.DialTLSContext = c.buildDialTLSContext(tlsCtx)
 	tr.DialTLSContext = c.buildDialTLSContext(tlsCtx)
 
 
 	// Add decorator if necessary and use this round tripper going forward
 	// Add decorator if necessary and use this round tripper going forward
-	rt := getTransportWithDecorator(tr, c.transportDecorator)
+	rt := decorateTransport(tr, c.transportDecorator)
 	renewer.RenewCertificate = getRenewFunc(tlsCtx, c, rt, pk) //nolint:contextcheck // deeply nested context
 	renewer.RenewCertificate = getRenewFunc(tlsCtx, c, rt, pk) //nolint:contextcheck // deeply nested context
 
 
 	// Update client transport
 	// Update client transport
@@ -184,7 +184,7 @@ func (c *Client) GetServerTLSConfig(ctx context.Context, sign *api.SignResponse,
 	tr.DialTLSContext = c.buildDialTLSContext(tlsCtx)
 	tr.DialTLSContext = c.buildDialTLSContext(tlsCtx)
 
 
 	// Add decorator if necessary and use this round tripper going forward
 	// Add decorator if necessary and use this round tripper going forward
-	rt := getTransportWithDecorator(tr, c.transportDecorator)
+	rt := decorateTransport(tr, c.transportDecorator)
 	renewer.RenewCertificate = getRenewFunc(tlsCtx, c, rt, pk) //nolint:contextcheck // deeply nested context
 	renewer.RenewCertificate = getRenewFunc(tlsCtx, c, rt, pk) //nolint:contextcheck // deeply nested context
 
 
 	// Update client transport
 	// Update client transport