Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unnecessary context #4

Merged
merged 1 commit into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func (s *AWSService) List(ctx context.Context) ([]*AWSAccount, *Response, error)
return nil, nil, fmt.Errorf("%w", err)
}

resp, err := s.client.do(ctx, req)
resp, err := s.client.do(req)
if err != nil {
return nil, resp, fmt.Errorf("%w", err)
}
Expand Down Expand Up @@ -159,7 +159,7 @@ func (s *AWSService) Create(ctx context.Context, account *AWSAccount) (*AWSAccou
return nil, nil, fmt.Errorf("%w", err)
}

resp, err := s.client.do(ctx, req)
resp, err := s.client.do(req)
if err != nil {
return nil, resp, fmt.Errorf("%w", err)
}
Expand Down Expand Up @@ -220,7 +220,7 @@ func (s *AWSService) Update(ctx context.Context, account *AWSAccount) (*Response
return nil, fmt.Errorf("%w", err)
}

resp, err := s.client.do(ctx, req)
resp, err := s.client.do(req)
if err != nil {
return resp, fmt.Errorf("%w", err)
}
Expand Down Expand Up @@ -259,7 +259,7 @@ func (s *AWSService) Delete(ctx context.Context, id string) (*Response, error) {
return nil, fmt.Errorf("%w", err)
}

resp, err := s.client.do(ctx, req)
resp, err := s.client.do(req)
if err != nil {
return resp, fmt.Errorf("%w", err)
}
Expand Down Expand Up @@ -329,7 +329,7 @@ func (s *AWSService) Snapshot(
return nil, nil, fmt.Errorf("%w", err)
}

resp, err := s.client.do(ctx, req)
resp, err := s.client.do(req)
if err != nil {
return nil, resp, fmt.Errorf("%w", err)
}
Expand Down Expand Up @@ -364,7 +364,7 @@ func (s *AWSService) IAMParameters(ctx context.Context) (*IAMParams, *Response,
return nil, nil, fmt.Errorf("%w", err)
}

resp, err := s.client.do(ctx, req)
resp, err := s.client.do(req)
if err != nil {
return nil, resp, fmt.Errorf("%w", err)
}
Expand Down Expand Up @@ -403,7 +403,7 @@ func (s *AWSService) IAMPolicy(ctx context.Context) (*IAMPolicy, *Response, erro
return nil, nil, fmt.Errorf("%w", err)
}

resp, err := s.client.do(ctx, req)
resp, err := s.client.do(req)
if err != nil {
return nil, resp, fmt.Errorf("%w", err)
}
Expand Down
10 changes: 5 additions & 5 deletions azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func (s *AzureService) List(ctx context.Context) ([]*AzureAccount, *Response, er
return nil, nil, fmt.Errorf("%w", err)
}

resp, err := s.client.do(ctx, req)
resp, err := s.client.do(req)
if err != nil {
return nil, resp, fmt.Errorf("%w", err)
}
Expand Down Expand Up @@ -157,7 +157,7 @@ func (s *AzureService) Create(ctx context.Context, account *AzureAccount) (*Azur
return nil, nil, fmt.Errorf("%w", err)
}

resp, err := s.client.do(ctx, req)
resp, err := s.client.do(req)
if err != nil {
return nil, resp, fmt.Errorf("%w", err)
}
Expand Down Expand Up @@ -230,7 +230,7 @@ func (s *AzureService) Update(ctx context.Context, account *AzureAccount) (*Resp
return nil, fmt.Errorf("%w", err)
}

resp, err := s.client.do(ctx, req)
resp, err := s.client.do(req)
if err != nil {
return resp, fmt.Errorf("%w", err)
}
Expand Down Expand Up @@ -269,7 +269,7 @@ func (s *AzureService) Delete(ctx context.Context, id string) (*Response, error)
return nil, fmt.Errorf("%w", err)
}

resp, err := s.client.do(ctx, req)
resp, err := s.client.do(req)
if err != nil {
return resp, fmt.Errorf("%w", err)
}
Expand Down Expand Up @@ -339,7 +339,7 @@ func (s *AzureService) Snapshot(
return nil, nil, fmt.Errorf("%w", err)
}

resp, err := s.client.do(ctx, req)
resp, err := s.client.do(req)
if err != nil {
return nil, resp, fmt.Errorf("%w", err)
}
Expand Down
14 changes: 7 additions & 7 deletions blueprint.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ func (s *BlueprintService) List(ctx context.Context) ([]*Blueprint, *Response, e
return nil, nil, fmt.Errorf("%w", err)
}

ret, err := s.client.do(ctx, req)
ret, err := s.client.do(req)
if err != nil {
return nil, nil, fmt.Errorf("%w", err)
}
Expand Down Expand Up @@ -276,7 +276,7 @@ func (s *BlueprintService) Get(ctx context.Context, id string) (*Blueprint, *Res
return nil, nil, fmt.Errorf("%w", err)
}

resp, err := s.client.do(ctx, req)
resp, err := s.client.do(req)
if err != nil {
return nil, nil, fmt.Errorf("%w", err)
}
Expand Down Expand Up @@ -323,7 +323,7 @@ func (s *BlueprintService) Create(ctx context.Context, blueprint *Blueprint) (*B
return nil, nil, fmt.Errorf("%w", err)
}

resp, err := s.client.do(ctx, req)
resp, err := s.client.do(req)
if err != nil {
return nil, nil, fmt.Errorf("%w", err)
}
Expand Down Expand Up @@ -379,7 +379,7 @@ func (s *BlueprintService) Update(ctx context.Context, blueprint *Blueprint, eta
req.Header.Set("If-Match", etag)
}

resp, err := s.client.do(ctx, req)
resp, err := s.client.do(req)
if err != nil {
return nil, fmt.Errorf("%w", err)
}
Expand Down Expand Up @@ -417,7 +417,7 @@ func (s *BlueprintService) Delete(ctx context.Context, id string) (*Response, er
return nil, fmt.Errorf("%w", err)
}

resp, err := s.client.do(ctx, req)
resp, err := s.client.do(req)
if err != nil {
return nil, fmt.Errorf("%w", err)
}
Expand Down Expand Up @@ -479,7 +479,7 @@ func (s *BlueprintService) ExportImage(
return nil, nil, fmt.Errorf("%w", err)
}

resp, err := s.client.do(ctx, req)
resp, err := s.client.do(req)
if err != nil {
return nil, nil, fmt.Errorf("%w", err)
}
Expand Down Expand Up @@ -541,7 +541,7 @@ func (s *BlueprintService) ExportBudget(
return nil, nil, fmt.Errorf("%w", err)
}

resp, err := s.client.do(ctx, req)
resp, err := s.client.do(req)
if err != nil {
return nil, nil, fmt.Errorf("%w", err)
}
Expand Down
7 changes: 2 additions & 5 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,14 +191,11 @@ type Response struct {
}

// do performs an HTTP request using the underlying HTTP client.
func (c *Client) do(ctx context.Context, req *http.Request) (*Response, error) {
if err := c.rateLimiter.Wait(ctx); err != nil {
func (c *Client) do(req *http.Request) (*Response, error) {
if err := c.rateLimiter.Wait(req.Context()); err != nil {
return nil, fmt.Errorf("%w", err)
}

// Use the context from the parameter.
req = req.WithContext(ctx)

resp, err := c.httpClient.Do(req)
if err != nil {
select {
Expand Down
2 changes: 1 addition & 1 deletion client_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ func TestDo(t *testing.T) {
t.Fatalf("Request() error = %v", err)
}

got, err := client.do(tt.context, req)
got, err := client.do(req)
if (err != nil) != tt.wantErr {
t.Fatalf("Do() error = %v, wantErr %v", err, tt.wantErr)
}
Expand Down
2 changes: 1 addition & 1 deletion user.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func (s *UserService) Me(ctx context.Context) (*User, *Response, error) {
return nil, nil, err
}

ret, err := s.client.do(ctx, req)
ret, err := s.client.do(req)
if err != nil {
return nil, nil, err
}
Expand Down
Loading