Merge pull request #13383 from luisdavim/retryingrt

chore: Make retryingRoundTripper type public
pull/12620/head
Matt Farina 4 weeks ago committed by GitHub
commit 5af4707f22
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -36,6 +36,7 @@ import (
"helm.sh/helm/v3/internal/version"
"helm.sh/helm/v3/pkg/helmpath"
"helm.sh/helm/v3/pkg/kube"
)
// defaultMaxHistory sets the maximum number of releases to 0: unlimited
@ -127,7 +128,7 @@ func New() *EnvSettings {
config.Burst = env.BurstLimit
config.QPS = env.QPS
config.Wrap(func(rt http.RoundTripper) http.RoundTripper {
return &retryingRoundTripper{wrapped: rt}
return &kube.RetryingRoundTripper{Wrapped: rt}
})
config.UserAgent = version.GetUserAgent()
return config

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
package cli
package kube
import (
"bytes"
@ -24,19 +24,19 @@ import (
"strings"
)
type retryingRoundTripper struct {
wrapped http.RoundTripper
type RetryingRoundTripper struct {
Wrapped http.RoundTripper
}
func (rt *retryingRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
func (rt *RetryingRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) {
return rt.roundTrip(req, 1, nil)
}
func (rt *retryingRoundTripper) roundTrip(req *http.Request, retry int, prevResp *http.Response) (*http.Response, error) {
func (rt *RetryingRoundTripper) roundTrip(req *http.Request, retry int, prevResp *http.Response) (*http.Response, error) {
if retry < 0 {
return prevResp, nil
}
resp, rtErr := rt.wrapped.RoundTrip(req)
resp, rtErr := rt.Wrapped.RoundTrip(req)
if rtErr != nil {
return resp, rtErr
}
Loading…
Cancel
Save