Skip to content

Conversation

@sivchari
Copy link
Contributor

@sivchari sivchari commented Apr 1, 2025

Currently, go-server-sdk doesn't provide way to handle scheme and it's hard to debug on local since the all request send to as a HTTPS.
By making client's scheme configurable, we can use client not only hosting environment but also local one.

@sivchari sivchari requested a review from cre8ivejp as a code owner April 1, 2025 11:02
@sivchari sivchari force-pushed the add-scheme-configuration branch 2 times, most recently from 3a750a6 to 4ddd70e Compare April 1, 2025 11:40
@cre8ivejp cre8ivejp requested review from Copilot, hvn2k1 and nnnkkk7 April 2, 2025 08:07
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a configurable scheme for the Bucketeer SDK, allowing the client to use either HTTP or HTTPS for API requests.

  • Adds a scheme option to the Bucketeer options and default configuration.
  • Updates tests to cover the new scheme option.
  • Modifies API client URL construction to use the configurable scheme.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
pkg/bucketeer/sdk.go Updated API client instantiation to pass the scheme configuration.
pkg/bucketeer/option_test.go Added tests to assert correct scheme configuration.
pkg/bucketeer/option.go Introduced scheme in options with a default value and the corresponding setter.
pkg/bucketeer/api/client.go Added error definitions and validation for scheme, but missing assignment in client constructor.
pkg/bucketeer/api/api.go Modified API URL constructions to use the configurable scheme.
Comments suppressed due to low confidence (1)

pkg/bucketeer/api/client.go:65

  • The ClientConfig's scheme field is not assigned to the client struct. Consider assigning the scheme (e.g., scheme: string(conf.Scheme)) to ensure that the URL is constructed using the configured scheme.
client := &client{ apiKey: conf.APIKey, host: conf.Host, }

@sivchari sivchari force-pushed the add-scheme-configuration branch 4 times, most recently from 24c820b to 8a0f3da Compare April 4, 2025 15:12
@sivchari
Copy link
Contributor Author

sivchari commented Apr 4, 2025

Hi, @cre8ivejp
If you have time to handle it, please push it to queue for reviewing. PTAL

Copy link
Member

@cre8ivejp cre8ivejp left a comment

Choose a reason for hiding this comment

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

Thank you so much for your contribution!
I left a few comments. Please take a look when you have time.

}
if c.scheme == "http" {
client.Transport = &http.Transport{
// This setting is for developping on local machine.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// This setting is for developping on local machine.
// This setting is for developing on local machines.

@sivchari sivchari force-pushed the add-scheme-configuration branch from 8a0f3da to e8d61f4 Compare April 7, 2025 08:32
@sivchari
Copy link
Contributor Author

sivchari commented Apr 7, 2025

@cre8ivejp
Thanks for the comment. Your suggestions apply to PR. PTAL.

Copy link
Collaborator

@Ubisoft-potato Ubisoft-potato left a comment

Choose a reason for hiding this comment

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

LGTM!

@cre8ivejp
Copy link
Member

@sivchari, the e2e tests are failing.

=== NAME  TestGetSegmentUsers
    api_test.go:78: 
        	Error Trace:	/home/runner/work/go-server-sdk/go-server-sdk/test/e2e/api_test.go:227
        	            				/home/runner/work/go-server-sdk/go-server-sdk/test/e2e/api_test.go:78
        	Error:      	Received unexpected error:
        	            	scheme must be http or https
        	Test:       	TestGetSegmentUsers
--- FAIL: TestGetSegmentUsers (0.00s)

You must also update here.
https://github.com/bucketeer-io/go-server-sdk/blob/master/test/e2e/api_test.go#L222-L225

@sivchari sivchari force-pushed the add-scheme-configuration branch 2 times, most recently from 13b193f to 54fcfde Compare April 12, 2025 07:08
Signed-off-by: sivchari <shibuuuu5@gmail.com>
@sivchari sivchari force-pushed the add-scheme-configuration branch from 54fcfde to b542494 Compare April 12, 2025 07:17
@sivchari
Copy link
Contributor Author

@cre8ivejp
Ups, Thx!

@sivchari
Copy link
Contributor Author

ping

Copy link
Member

@cre8ivejp cre8ivejp left a comment

Choose a reason for hiding this comment

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

Once again, thank you so much for your contribution 🎉

@cre8ivejp cre8ivejp merged commit 3ca01d3 into bucketeer-io:master Apr 16, 2025
6 checks passed
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