(k8s client.Client, logger logr.Logger)
| 68 | } |
| 69 | |
| 70 | func SetupHttpClientsFactory(k8s client.Client, logger logr.Logger) error { |
| 71 | systemCertPool, err := x509.SystemCertPool() |
| 72 | if err != nil { |
| 73 | return fmt.Errorf("failed to load system cert pool: %w", err) |
| 74 | } |
| 75 | |
| 76 | proxyFunc := getProxyFunc() |
| 77 | |
| 78 | healthCheckHttpClientTransport := http.DefaultTransport.(*http.Transport).Clone() |
| 79 | if proxyFunc != nil { |
| 80 | // Preserve the default proxy (from env vars) when no explicit proxy is configured. |
| 81 | healthCheckHttpClientTransport.Proxy = proxyFunc |
| 82 | } |
| 83 | healthCheckHttpClientTransport.TLSClientConfig = &tls.Config{ |
| 84 | InsecureSkipVerify: true, |
| 85 | } |
| 86 | |
| 87 | httpClientsFactory = &DefaultHttpClientsFactory{ |
| 88 | k8s: k8s, |
| 89 | logger: logger, |
| 90 | systemCertPool: systemCertPool, |
| 91 | proxyFunc: proxyFunc, |
| 92 | healthCheckHttpClient: &http.Client{ |
| 93 | Transport: healthCheckHttpClientTransport, |
| 94 | Timeout: 500 * time.Millisecond, |
| 95 | }, |
| 96 | } |
| 97 | |
| 98 | return nil |
| 99 | } |
| 100 | |
| 101 | func (h *DefaultHttpClientsFactory) GetHttpClient(ctx context.Context, routingConfig *controller.RoutingConfig) *http.Client { |
| 102 | certsCM := h.readCertificates(ctx, routingConfig) |
no test coverage detected