Skip to content

Commit

Permalink
Merge pull request #161 from conductor-sdk/feature/with-context-execu…
Browse files Browse the repository at this point in the history
…tor-fns

Add `WithContext` functions to executor
  • Loading branch information
jmigueprieto authored Nov 7, 2024
2 parents 283f031 + 6f17031 commit 3891d83
Show file tree
Hide file tree
Showing 8 changed files with 514 additions and 299 deletions.
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 {
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)
}

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)
} 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"`
Name string `json:"name"`
}
Loading

0 comments on commit 3891d83

Please sign in to comment.