MCPcopy Create free account
hub / github.com/devfile/devworkspace-operator / SetupHttpClientsFactory

Function SetupHttpClientsFactory

controllers/workspace/http.go:70–99  ·  view source on GitHub ↗
(k8s client.Client, logger logr.Logger)

Source from the content-addressed store, hash-verified

68}
69
70func 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
101func (h *DefaultHttpClientsFactory) GetHttpClient(ctx context.Context, routingConfig *controller.RoutingConfig) *http.Client {
102 certsCM := h.readCertificates(ctx, routingConfig)

Callers 1

SetupWithManagerMethod · 0.85

Calls 1

getProxyFuncFunction · 0.85

Tested by

no test coverage detected