@@ -16,13 +16,6 @@ package client
1616
1717import (
1818 "context"
19- "crypto/tls"
20- "crypto/x509"
21- "io/ioutil"
22- "net"
23- "net/http"
24- "net/url"
25- "os"
2619 "time"
2720
2821 "github.com/oracle/oci-go-sdk/v65/common"
@@ -170,6 +163,7 @@ type client struct {
170163
171164// New constructs an OCI API client.
172165func New (logger * zap.SugaredLogger , cp common.ConfigurationProvider , opRateLimiter * RateLimiter ) (Interface , error ) {
166+
173167 compute , err := core .NewComputeClientWithConfigurationProvider (cp )
174168 if err != nil {
175169 return nil , errors .Wrap (err , "NewComputeClientWithConfigurationProvider" )
@@ -361,51 +355,5 @@ func (c *client) FSS() FileStorageInterface {
361355}
362356
363357func configureCustomTransport (logger * zap.SugaredLogger , baseClient * common.BaseClient ) error {
364- httpClient := baseClient .HTTPClient .(* http.Client )
365-
366- var transport * http.Transport
367- if httpClient .Transport == nil {
368- transport = & http.Transport {
369- DialContext : (& net.Dialer {
370- Timeout : 30 * time .Second ,
371- KeepAlive : 30 * time .Second ,
372- DualStack : true ,
373- }).DialContext ,
374- MaxIdleConns : 100 ,
375- IdleConnTimeout : 90 * time .Second ,
376- TLSHandshakeTimeout : 10 * time .Second ,
377- ExpectContinueTimeout : 1 * time .Second ,
378- }
379- } else {
380- transport = httpClient .Transport .(* http.Transport )
381- }
382-
383- ociProxy := os .Getenv ("OCI_PROXY" )
384- if ociProxy != "" {
385- proxyURL , err := url .Parse (ociProxy )
386- if err != nil {
387- return errors .Wrapf (err , "failed to parse OCI proxy url: %s" , ociProxy )
388- }
389- transport .Proxy = func (req * http.Request ) (* url.URL , error ) {
390- return proxyURL , nil
391- }
392- }
393-
394- trustedCACertPath := os .Getenv ("TRUSTED_CA_CERT_PATH" )
395- if trustedCACertPath != "" {
396- logger .With ("path" , trustedCACertPath ).Infof ("Configuring OCI client with a new trusted ca" )
397- trustedCACert , err := ioutil .ReadFile (trustedCACertPath )
398- if err != nil {
399- return errors .Wrapf (err , "failed to read root certificate: %s" , trustedCACertPath )
400- }
401- caCertPool := x509 .NewCertPool ()
402- ok := caCertPool .AppendCertsFromPEM (trustedCACert )
403- if ! ok {
404- return errors .Wrapf (err , "failed to parse root certificate: %s" , trustedCACertPath )
405- }
406- transport .TLSClientConfig = & tls.Config {RootCAs : caCertPool }
407- }
408-
409- httpClient .Transport = transport
410358 return nil
411359}
0 commit comments