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

Add WithContext functions to executor #161

Merged
merged 3 commits into from
Nov 7, 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
6 changes: 2 additions & 4 deletions sdk/authentication/token_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,7 @@ func contains(haystack []string, needle string) bool {
}

func setBody(body interface{}, contentType string) (bodyBuf *bytes.Buffer, err error) {
if bodyBuf == nil {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unnecessary check

bodyBuf = &bytes.Buffer{}
}
bodyBuf = &bytes.Buffer{}
if reader, ok := body.(io.Reader); ok {
_, err = bodyBuf.ReadFrom(reader)
} else if b, ok := body.([]byte); ok {
Expand All @@ -248,7 +246,7 @@ func setBody(body interface{}, contentType string) (bodyBuf *bytes.Buffer, err e
} else if jsonCheck.MatchString(contentType) {
err = json.NewEncoder(bodyBuf).Encode(body)
} else if xmlCheck.MatchString(contentType) {
xml.NewEncoder(bodyBuf).Encode(body)
err = xml.NewEncoder(bodyBuf).Encode(body)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing error handling but I don't think this is being used

}

if err != nil {
Expand Down
7 changes: 3 additions & 4 deletions sdk/client/api_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,8 @@ func parameterToString(obj interface{}, collectionFormat string) string {
}

func setBody(body interface{}, contentType string) (bodyBuf *bytes.Buffer, err error) {
if bodyBuf == nil {
bodyBuf = &bytes.Buffer{}
}
bodyBuf = &bytes.Buffer{}

if reader, ok := body.(io.Reader); ok {
_, err = bodyBuf.ReadFrom(reader)
} else if b, ok := body.([]byte); ok {
Expand All @@ -261,7 +260,7 @@ func setBody(body interface{}, contentType string) (bodyBuf *bytes.Buffer, err e
} else if jsonCheck.MatchString(contentType) {
err = json.NewEncoder(bodyBuf).Encode(body)
} else if xmlCheck.MatchString(contentType) {
xml.NewEncoder(bodyBuf).Encode(body)
err = xml.NewEncoder(bodyBuf).Encode(body)
}

if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions sdk/client/http_requester.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,12 +139,12 @@ func (h *HttpRequester) prepareRequest(
// Encode the parameters.
url.RawQuery = query.Encode()

// Generate a new request
if body != nil {
localVarRequest, err = http.NewRequest(method, url.String(), body)
localVarRequest, err = http.NewRequestWithContext(ctx, method, url.String(), body)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

context was propagated but not used at all before these changes

} else {
localVarRequest, err = http.NewRequest(method, url.String(), nil)
localVarRequest, err = http.NewRequestWithContext(ctx, method, url.String(), nil)
}

if err != nil {
return nil, err
}
Expand Down
3 changes: 1 addition & 2 deletions sdk/model/rbac/create_or_update_application_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,5 @@ package rbac

type CreateOrUpdateApplicationRequest struct {
// Application's name e.g.: Payment Processors
Name string `json:"name"`
Description string `json"description"`
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is no description in CreateOrUpdateApplicationRequest

Name string `json:"name"`
}
Loading
Loading