Skip to content

Commit

Permalink
Remove redundant ClientOptions type
Browse files Browse the repository at this point in the history
  • Loading branch information
chlowell committed Feb 12, 2025
1 parent a0bb786 commit a20f226
Showing 1 changed file with 10 additions and 21 deletions.
31 changes: 10 additions & 21 deletions apps/managedidentity/managedidentity.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,16 +167,11 @@ type Client struct {
retryPolicyEnabled bool
}

type ClientOptions struct {
httpClient ops.HTTPClient
retryPolicyEnabled bool
}

type AcquireTokenOptions struct {
claims string
}

type ClientOption func(o *ClientOptions)
type ClientOption func(*Client)

type AcquireTokenOption func(o *AcquireTokenOptions)

Expand All @@ -190,14 +185,14 @@ func WithClaims(claims string) AcquireTokenOption {

// WithHTTPClient allows for a custom HTTP client to be set.
func WithHTTPClient(httpClient ops.HTTPClient) ClientOption {
return func(o *ClientOptions) {
o.httpClient = httpClient
return func(c *Client) {
c.httpClient = httpClient
}
}

func WithRetryPolicyDisabled() ClientOption {
return func(o *ClientOptions) {
o.retryPolicyEnabled = false
return func(c *Client) {
c.retryPolicyEnabled = false
}
}

Expand Down Expand Up @@ -235,15 +230,6 @@ func New(id ID, options ...ClientOption) (Client, error) {
}
}

opts := ClientOptions{
httpClient: shared.DefaultClient,
retryPolicyEnabled: true,
}

for _, option := range options {
option(&opts)
}

switch t := id.(type) {
case UserAssignedClientID:
if len(string(t)) == 0 {
Expand All @@ -263,10 +249,13 @@ func New(id ID, options ...ClientOption) (Client, error) {
}
client := Client{
miType: id,
httpClient: opts.httpClient,
retryPolicyEnabled: opts.retryPolicyEnabled,
httpClient: shared.DefaultClient,
retryPolicyEnabled: true,
source: source,
}
for _, option := range options {
option(&client)
}
fakeAuthInfo, err := authority.NewInfoFromAuthorityURI("https://login.microsoftonline.com/managed_identity", false, true)
if err != nil {
return Client{}, err
Expand Down

0 comments on commit a20f226

Please sign in to comment.