-
Notifications
You must be signed in to change notification settings - Fork 0
Introduce AccessKey type for improved type safety #46
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
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.
Pull Request Overview
This PR introduces a new AccessKey type (alias for string) and updates all related APIs to use methods on that type for better type safety. Key changes include:
- Defining
type AccessKey stringand converting free functions (GetProjectIDFromAccessKey,GenerateAccessKey,GetAccessKeyPrefix) into receiver methods onAccessKey. - Updating all context helpers, middleware, common utilities, CLI commands, and tests to use the new
AccessKeytype. - Adjusting
go.modto add direct dependencies (base64,base62,cobra) and remove duplicated indirect entries.
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| middleware.go | Switched calls from GetProjectIDFromAccessKey to accessKey.GetProjectID() and cast to string |
| common.go | Updated AccessKeyFunc and AccessKeyFromHeader to return AccessKey instead of string |
| context.go | Changed WithAccessKey/GetAccessKey signatures to use AccessKey |
| access_key.go | Introduced AccessKey type and moved encode/decode/free functions into methods on it |
| access_key_test.go | Updated tests to call accessKey.GetProjectID() |
| common_test.go | Changed keyFunc to return authcontrol.AccessKey |
| cmd/access_key/main.go | Cast CLI argument to authcontrol.AccessKey |
| go.mod | Added direct dependencies for base64, base62, cobra and cleaned up indirect entries |
Comments suppressed due to low confidence (2)
access_key.go:25
- Removing the free function GetProjectIDFromAccessKey is a breaking change; consider providing a wrapper or alias for backward compatibility to ease migration for existing consumers.
type AccessKey string
context.go:105
- Update the function comment to reflect that accessKey is now of type AccessKey instead of string to keep documentation in sync with the API.
func WithAccessKey(ctx context.Context, accessKey AccessKey) context.Context {
VojtechVitek
left a comment
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.
Looks good
…ate tests for consistency
7469cce to
b0d18bb
Compare
VojtechVitek
left a comment
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.
LGTM
This reverts commit 1a44627.
No description provided.