@@ -10,7 +10,6 @@ import (
1010 "net/http"
1111 "time"
1212
13- "go.opentelemetry.io/otel/trace"
1413 "golang.org/x/oauth2"
1514
1615 "github.com/hashicorp/go-retryablehttp"
@@ -20,16 +19,12 @@ import (
2019
2120type resilientOptions struct {
2221 c * http.Client
23- oauthConfig * oauth2.Config
24- oauthToken * oauth2.Token
2522 l interface {}
2623 retryWaitMin time.Duration
2724 retryWaitMax time.Duration
2825 retryMax int
2926 noInternalIPs bool
3027 internalIPExceptions []string
31- ipV6 bool
32- tracer trace.Tracer
3328}
3429
3530func newResilientOptions () * resilientOptions {
@@ -40,20 +35,12 @@ func newResilientOptions() *resilientOptions {
4035 retryWaitMax : 30 * time .Second ,
4136 retryMax : 4 ,
4237 l : log .New (io .Discard , "" , log .LstdFlags ),
43- ipV6 : true ,
4438 }
4539}
4640
4741// ResilientOptions is a set of options for the ResilientClient.
4842type ResilientOptions func (o * resilientOptions )
4943
50- // ResilientClientWithTracer wraps the http clients transport with a tracing instrumentation
51- func ResilientClientWithTracer (tracer trace.Tracer ) ResilientOptions {
52- return func (o * resilientOptions ) {
53- o .tracer = tracer
54- }
55- }
56-
5744// ResilientClientWithMaxRetry sets the maximum number of retries.
5845func ResilientClientWithMaxRetry (retryMax int ) ResilientOptions {
5946 return func (o * resilientOptions ) {
@@ -104,12 +91,6 @@ func ResilientClientAllowInternalIPRequestsTo(urlGlobs ...string) ResilientOptio
10491 }
10592}
10693
107- func ResilientClientNoIPv6 () ResilientOptions {
108- return func (o * resilientOptions ) {
109- o .ipV6 = false
110- }
111- }
112-
11394// NewResilientClient creates a new ResilientClient.
11495func NewResilientClient (opts ... ResilientOptions ) * retryablehttp.Client {
11596 o := newResilientOptions ()
@@ -119,12 +100,12 @@ func NewResilientClient(opts ...ResilientOptions) *retryablehttp.Client {
119100
120101 if o .noInternalIPs {
121102 o .c .Transport = & noInternalIPRoundTripper {
122- onWhitelist : ifelse ( o . ipV6 , allowInternalAllowIPv6 , allowInternalProhibitIPv6 ) ,
123- notOnWhitelist : ifelse ( o . ipV6 , prohibitInternalAllowIPv6 , prohibitInternalProhibitIPv6 ) ,
103+ onWhitelist : allowInternalAllowIPv6 ,
104+ notOnWhitelist : prohibitInternalAllowIPv6 ,
124105 internalIPExceptions : o .internalIPExceptions ,
125106 }
126107 } else {
127- o .c .Transport = ifelse ( o . ipV6 , allowInternalAllowIPv6 , allowInternalProhibitIPv6 )
108+ o .c .Transport = allowInternalAllowIPv6
128109 }
129110
130111 cl := retryablehttp .NewClient ()
@@ -155,10 +136,3 @@ func SetOAuth2(ctx context.Context, cl *retryablehttp.Client, c OAuth2Config, t
155136type OAuth2Config interface {
156137 Client (context.Context , * oauth2.Token ) * http.Client
157138}
158-
159- func ifelse [A any ](b bool , x , y A ) A {
160- if b {
161- return x
162- }
163- return y
164- }
0 commit comments