@@ -42,31 +42,21 @@ import (
4242 "github.com/cortexlabs/cortex/pkg/operator/api/schema"
4343)
4444
45- type cortexClient struct {
46- * http. Client
45+ var httpTransport = & http. Transport {
46+ TLSClientConfig : & tls. Config { InsecureSkipVerify : true },
4747}
4848
49- var httpClient = & cortexClient {
50- Client : & http.Client {
51- Timeout : time .Second * 20 ,
52- },
53- }
54-
55- var httpsNoVerifyClient = & cortexClient {
56- Client : & http.Client {
57- Timeout : time .Second * 20 ,
58- Transport : & http.Transport {
59- TLSClientConfig : & tls.Config {InsecureSkipVerify : true },
60- },
61- },
49+ var httpClient = & http.Client {
50+ Timeout : time .Second * 20 ,
51+ Transport : httpTransport ,
6252}
6353
6454func HTTPGet (endpoint string , qParams ... map [string ]string ) ([]byte , error ) {
6555 req , err := operatorRequest ("GET" , endpoint , nil , qParams )
6656 if err != nil {
6757 return nil , err
6858 }
69- return httpsNoVerifyClient . makeRequest (req )
59+ return makeRequest (req )
7060}
7161
7262func HTTPPostJSONData (endpoint string , requestData interface {}, qParams ... map [string ]string ) ([]byte , error ) {
@@ -84,7 +74,7 @@ func HTTPPostJSON(endpoint string, jsonRequestData []byte, qParams ...map[string
8474 return nil , err
8575 }
8676 req .Header .Set ("Content-Type" , "application/json" )
87- return httpsNoVerifyClient . makeRequest (req )
77+ return makeRequest (req )
8878}
8979
9080type HTTPUploadInput struct {
@@ -124,7 +114,7 @@ func HTTPUpload(endpoint string, input *HTTPUploadInput, qParams ...map[string]s
124114 }
125115
126116 req .Header .Set ("Content-Type" , writer .FormDataContentType ())
127- return httpsNoVerifyClient . makeRequest (req )
117+ return makeRequest (req )
128118}
129119
130120func addFileToMultipart (fileName string , writer * multipart.Writer , reader io.Reader ) error {
@@ -264,11 +254,11 @@ func operatorRequest(method string, endpoint string, body io.Reader, qParams []m
264254 return req , nil
265255}
266256
267- func ( client * cortexClient ) makeRequest (request * http.Request ) ([]byte , error ) {
257+ func makeRequest (request * http.Request ) ([]byte , error ) {
268258 request .Header .Set ("Authorization" , authHeader ())
269259 request .Header .Set ("CortexAPIVersion" , consts .CortexVersion )
270260
271- response , err := client .Do (request )
261+ response , err := httpClient .Do (request )
272262 if err != nil {
273263 cliConfig := getValidCliConfig ()
274264 return nil , ErrorFailedToConnect (cliConfig .CortexURL )
0 commit comments