mirror of
https://github.com/replicatedhq/troubleshoot.git
synced 2026-04-15 07:16:34 +00:00
Merge pull request #364 from replicatedhq/divolgin/insecure
Do insecure upload if user allows it
This commit is contained in:
@@ -246,11 +246,11 @@ func parseTimeFlags(v *viper.Viper) (*time.Time, error) {
|
||||
return &sinceTime, nil
|
||||
}
|
||||
|
||||
func shouldRetryRequest(err error, httpClient *http.Client) bool {
|
||||
if strings.Contains(err.Error(), "x509") && httpClient == http.DefaultClient && canTryInsecure() {
|
||||
httpClient = &http.Client{Transport: &http.Transport{
|
||||
func shouldRetryRequest(err error) bool {
|
||||
if strings.Contains(err.Error(), "x509") && canTryInsecure() {
|
||||
httputil.AddTransport(&http.Transport{
|
||||
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
|
||||
}}
|
||||
})
|
||||
return true
|
||||
}
|
||||
return false
|
||||
|
||||
@@ -29,7 +29,7 @@ import (
|
||||
|
||||
var scheme = runtime.NewScheme()
|
||||
var codecs = serializer.NewCodecFactory(scheme)
|
||||
|
||||
var parameterCodec = runtime.NewParameterCodec(scheme)
|
||||
var localSchemeBuilder = runtime.SchemeBuilder{
|
||||
troubleshootv1beta1.AddToScheme,
|
||||
troubleshootv1beta2.AddToScheme,
|
||||
|
||||
@@ -14,7 +14,6 @@ func AddTransport(transport *http.Transport) {
|
||||
}
|
||||
|
||||
func GetHttpClient() *http.Client {
|
||||
|
||||
if httpTransport != nil {
|
||||
httpClient.Transport = httpTransport
|
||||
return httpClient
|
||||
|
||||
@@ -48,7 +48,7 @@ func uploadSupportBundle(r *troubleshootv1beta2.ResultRequest, archivePath strin
|
||||
httpClient := httputil.GetHttpClient()
|
||||
resp, err := httpClient.Do(req)
|
||||
if err != nil {
|
||||
if shouldRetryRequest(err, httpClient) {
|
||||
if shouldRetryRequest(err) {
|
||||
continue
|
||||
}
|
||||
return errors.Wrap(err, "execute request")
|
||||
@@ -82,7 +82,7 @@ func uploadSupportBundle(r *troubleshootv1beta2.ResultRequest, archivePath strin
|
||||
httpClient := httputil.GetHttpClient()
|
||||
resp, err := httpClient.Do(req)
|
||||
if err != nil {
|
||||
if shouldRetryRequest(err, httpClient) {
|
||||
if shouldRetryRequest(err) {
|
||||
continue
|
||||
}
|
||||
return errors.Wrap(err, "execute redaction request")
|
||||
@@ -109,7 +109,7 @@ func callbackSupportBundleAPI(r *troubleshootv1beta2.ResultRequest, archivePath
|
||||
httpClient := httputil.GetHttpClient()
|
||||
resp, err := httpClient.Do(req)
|
||||
if err != nil {
|
||||
if shouldRetryRequest(err, httpClient) {
|
||||
if shouldRetryRequest(err) {
|
||||
continue
|
||||
}
|
||||
return errors.Wrap(err, "execute request")
|
||||
@@ -133,11 +133,11 @@ func getExpectedContentType(uploadURL string) string {
|
||||
return parsedURL.Query().Get("Content-Type")
|
||||
}
|
||||
|
||||
func shouldRetryRequest(err error, httpClient *http.Client) bool {
|
||||
if strings.Contains(err.Error(), "x509") && httpClient == http.DefaultClient && canTryInsecure() {
|
||||
httpClient = &http.Client{Transport: &http.Transport{
|
||||
func shouldRetryRequest(err error) bool {
|
||||
if strings.Contains(err.Error(), "x509") && canTryInsecure() {
|
||||
httputil.AddTransport(&http.Transport{
|
||||
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
|
||||
}}
|
||||
})
|
||||
return true
|
||||
}
|
||||
return false
|
||||
|
||||
@@ -182,7 +182,7 @@ func loadSpecFromURL(arg string) ([]byte, error) {
|
||||
httpClient := httputil.GetHttpClient()
|
||||
resp, err := httpClient.Do(req)
|
||||
if err != nil {
|
||||
if shouldRetryRequest(err, httpClient) {
|
||||
if shouldRetryRequest(err) {
|
||||
continue
|
||||
}
|
||||
return nil, errors.Wrap(err, "execute request")
|
||||
|
||||
Reference in New Issue
Block a user