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

[Fix] Support Query parameters for all HTTP operations #1124

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

hectorcast-db
Copy link
Contributor

What changes are proposed in this pull request?

Support Query parameters for all HTTP operations. Previously, only GET/HEAD/DELETE were supported.

How is this tested?

  • Added Unit Tests
  • Run Integration Tests

Comment on lines 48 to 52
},
nil,
map[string]string{
"c": "d",
}, nil)
Copy link
Contributor

Choose a reason for hiding this comment

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

This formatting is hard to read and not consistent, let's do something slightly more idiomatic:

err = c.Do(
	context.Background(), 
	"GET", 
	"/a/b", 
	map[string]string{"e": "f"},
	nil,
	map[string]string{"c": "d"},
	nil,
)

Also applies to other tests.

},
nil,
map[string]string{
"c": "d",
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we also cover cases where the value is not a string?

Copy link

If integration tests don't run automatically, an authorized user can run them manually by following the instructions below:

Trigger:
go/deco-tests-run/sdk-go

Inputs:

  • PR number: 1124
  • Commit SHA: 279f0c5d9373a312931a58a4138b47bd08db93c9

Checks will be approved automatically on success.

@@ -141,3 +141,26 @@ func TestEncodeMultiSegmentPathParameter(t *testing.T) {
// # and ? should be encoded.
assert.Equal(t, "a%23b%3Fc", EncodeMultiSegmentPathParameter("a#b?c"))
}

func TestMakeRequestBodyExplicitQueryParams(t *testing.T) {
type x struct {
Copy link
Contributor

Choose a reason for hiding this comment

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

To be clear, the first scenario should not happen, IIUC. For GET/HEAD/DELETE requests, extra query parameters are never passed in.

Could the second scenario happen, where the request contains url tags that are overridden by the explicit query parameters?

@@ -63,12 +63,13 @@ func (c *DatabricksClient) GetOAuthToken(ctx context.Context, authDetails string

// Do sends an HTTP request against path.
func (c *DatabricksClient) Do(ctx context.Context, method, path string,
headers map[string]string, request, response any,
headers map[string]string, queryParams map[string]any, request, response any,
Copy link
Contributor

Choose a reason for hiding this comment

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

For external clients (like Terraform), the migration path is to pass nil for GET/HEAD/DELETE requests and to explicitly pass the query parameters here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants