|
|
@ -27,7 +27,6 @@ package decort
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"bytes"
|
|
|
|
"crypto/tls"
|
|
|
|
"crypto/tls"
|
|
|
|
"errors"
|
|
|
|
|
|
|
|
"fmt"
|
|
|
|
"fmt"
|
|
|
|
"io/ioutil"
|
|
|
|
"io/ioutil"
|
|
|
|
"net/http"
|
|
|
|
"net/http"
|
|
|
@ -140,12 +139,9 @@ func ControllerConfigure(d *schema.ResourceData) (*ControllerCfg, error) {
|
|
|
|
transCfg := &http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: true}} //nolint:gosec
|
|
|
|
transCfg := &http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: true}} //nolint:gosec
|
|
|
|
ret_config.cc_client = &http.Client{
|
|
|
|
ret_config.cc_client = &http.Client{
|
|
|
|
Transport: transCfg,
|
|
|
|
Transport: transCfg,
|
|
|
|
Timeout: Timeout180s,
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
ret_config.cc_client = &http.Client{
|
|
|
|
ret_config.cc_client = &http.Client{}
|
|
|
|
Timeout: Timeout180s, // time.Second * 30,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
switch ret_config.auth_mode_code {
|
|
|
|
switch ret_config.auth_mode_code {
|
|
|
@ -379,13 +375,15 @@ func (config *ControllerCfg) decortAPICall(method string, api_name string, url_v
|
|
|
|
req.Header.Set("Authorization", fmt.Sprintf("bearer %s", config.jwt))
|
|
|
|
req.Header.Set("Authorization", fmt.Sprintf("bearer %s", config.jwt))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var resp *http.Response
|
|
|
|
|
|
|
|
var body []byte
|
|
|
|
for i := 0; i < 5; i++ {
|
|
|
|
for i := 0; i < 5; i++ {
|
|
|
|
resp, err := config.cc_client.Do(req)
|
|
|
|
resp, err = config.cc_client.Do(req)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return "", err
|
|
|
|
return "", err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
body, err := ioutil.ReadAll(resp.Body)
|
|
|
|
body, err = ioutil.ReadAll(resp.Body)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return "", err
|
|
|
|
return "", err
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -405,5 +403,6 @@ func (config *ControllerCfg) decortAPICall(method string, api_name string, url_v
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return "", errors.New("number of retries exceeded")
|
|
|
|
return "", fmt.Errorf("decortAPICall: unexpected status code %d when calling API %q with request Body %q. Respone:\n%s",
|
|
|
|
|
|
|
|
resp.StatusCode, req.URL, params_str, body)
|
|
|
|
}
|
|
|
|
}
|
|
|
|