Skip to content

Commit

Permalink
Fix bug with unspecified HTTPClient (#1938)
Browse files Browse the repository at this point in the history
  • Loading branch information
matthchr authored Oct 28, 2021
1 parent 2895dcb commit 7720077
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions v2/internal/genericarmclient/generic_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,24 @@ type GenericClient struct {
// TODO: Need to do retryAfter detection in each call?

func NewARMConnection(creds azcore.TokenCredential, httpClient *http.Client) *arm.Connection {
opts := &arm.ConnectionOptions{
Retry: policy.RetryOptions{
MaxRetries: 0,
},
PerCallPolicies: []policy.Policy{NewUserAgentPolicy(userAgent)},
DisableRPRegistration: true,
}
// We assign this HTTPClient like this because if we actually set it to nil, due to the way
// go interfaces wrap values, the subsequent if httpClient == nil check returns false (even though
// the value IN the interface IS nil).
if httpClient != nil {
opts.HTTPClient = httpClient
}

con := arm.NewConnection(
arm.AzurePublicCloud,
creds,
&arm.ConnectionOptions{
Retry: policy.RetryOptions{
MaxRetries: 0,
},
PerCallPolicies: []policy.Policy{NewUserAgentPolicy(userAgent)},
DisableRPRegistration: true,
HTTPClient: httpClient,
})
opts)
return con
}

Expand Down

0 comments on commit 7720077

Please sign in to comment.