-
Notifications
You must be signed in to change notification settings - Fork 1
Added pointer support for dynamic config #4
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.
There was a problem hiding this 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 pull request converts several configuration fields from basic types to pointers to improve optional handling and default value management in the OAuth2 configuration. The key changes include:
- Updating the Config struct and its accessor functions to use pointers.
- Adjusting tests and example commands to accommodate the new pointer-based configuration.
- Modifying the authentication logic to handle pointer dereferencing consistently.
Reviewed Changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
pkg/auth/device_code.go | Updated to dereference pointer fields when constructing the request. |
pkg/auth/config_test.go | Updated tests to build config with pointer values and perform pointer-based comparisons. |
pkg/auth/config.go | Changed Config struct fields and Option functions to use pointers; potential issue in WithDiscoveryURL. |
pkg/auth/cmd.go | Updated command functions to dereference pointer fields. |
pkg/auth/client_credentials.go | Updated payload construction to use pointers for config fields. |
pkg/auth/access_token_test.go | Updated tests to use helper function for pointer creation. |
pkg/auth/access_token.go | Modified pointer dereferencing in HTTP request construction. |
examples/client_credentials/cmd/root.go | Changed constant credentials to variables and updated pointers usage. |
examples/basic/cmd/root.go | Changed constant credentials to variables and updated pointers usage. |
Welcome to Codecov 🎉Once you merge this PR into your default branch, you're all set! Codecov will compare coverage reports and display results in all future pull requests. ℹ️ You can also turn on project coverage checks and project coverage reporting on Pull Request comment Thanks for integrating Codecov - We've got you covered ☂️ |
This pull request includes several changes aimed at improving the flexibility and robustness of the OAuth2 configuration and usage within the codebase. The primary focus is on converting configuration fields from basic types to pointers, allowing for better handling of optional and default values.
Changes to Configuration Handling:
pkg/auth/config.go
: Updated theConfig
struct to use pointer types for fields such asClientId
,ClientSecret
,DeviceAuthorizationEndpoint
,TokenEndpoint
,Scopes
,Audience
,StorageProvider
, andGrantType
. This change allows these fields to be optional and simplifies the handling of default values.pkg/auth/config.go
: Modified variousWith*
functions to accept pointers, aligning with the updatedConfig
struct. This includes functions likeWithClientID
,WithClientSecret
,WithDeviceAuthorizationEndpoint
,WithTokenEndpoint
,WithScopes
,WithAudience
,WithDiscoveryURL
,WithStorageProvider
, andWithGrantType
. [1] [2]Changes to Example Commands:
examples/basic/cmd/root.go
: ChangedCLIENT_ID
from a constant to a variable and updated its usage to pass pointers where required. [1] [2]examples/client_credentials/cmd/root.go
: Similarly, changedCLIENT_ID
andCLIENT_SECRET
from constants to variables and updated their usage to pass pointers. [1] [2]Changes to Authentication Logic:
pkg/auth/access_token.go
: Updated thePollForAccessToken
function to use pointer dereferencing forClientId
,ClientSecret
, andTokenEndpoint
fields in theConfig
struct. [1] [2] [3]pkg/auth/client_credentials.go
: Modified theFetchClientCredentialsToken
function to use pointer dereferencing forClientId
,ClientSecret
,TokenEndpoint
,Scopes
, andAudience
fields in theConfig
struct.Changes to Command Execution:
pkg/auth/cmd.go
: Updated various command functions to use pointer dereferencing forClientId
andGrantType
fields in theConfig
struct, ensuring consistent handling of these fields. [1] [2] [3] [4]Changes to Tests:
pkg/auth/config_test.go
: Updated tests to accommodate the changes in theConfig
struct, including the use of helper functions likestrPtr
to create string pointers and updating mock storage provider initialization. [1] [2] [3]pkg/auth/access_token_test.go
: Added a helper functionstrPtr
to create string pointers and updated theTestPollForAccessToken
function to use these pointers. [1] [2]These changes collectively enhance the flexibility and robustness of the OAuth2 configuration and usage, making the codebase more adaptable to different scenarios and configurations.