From ab3c589809a163cb4227063c04da706e3a60ca2a Mon Sep 17 00:00:00 2001 From: Luis Davim Date: Tue, 8 Oct 2024 20:45:37 +0100 Subject: [PATCH] chore: Make retryingRoundTripper type public Make retryingRoundTripper type public to allow being used in other projects fixes: #13052 Signed-off-by: Luis Davim --- pkg/cli/environment.go | 3 ++- pkg/{cli => kube}/roundtripper.go | 12 ++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) rename pkg/{cli => kube}/roundtripper.go (87%) diff --git a/pkg/cli/environment.go b/pkg/cli/environment.go index 0f28c61fd..635806344 100644 --- a/pkg/cli/environment.go +++ b/pkg/cli/environment.go @@ -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 diff --git a/pkg/cli/roundtripper.go b/pkg/kube/roundtripper.go similarity index 87% rename from pkg/cli/roundtripper.go rename to pkg/kube/roundtripper.go index 9cd4eacba..fdb103529 100644 --- a/pkg/cli/roundtripper.go +++ b/pkg/kube/roundtripper.go @@ -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 }