Refactor and add BucketAccessor in preparation of framework migration for bucket resource#2240
Open
zliang-akamai wants to merge 2 commits intolinode:zhiwei/obj-region-validationfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors object storage key resolution logic by introducing a BucketAccessor interface and centralizing the key retrieval logic in preparation for framework migration of the bucket resource. The changes improve code maintainability by extracting common patterns into reusable abstractions.
Changes:
- Introduced
BucketAccessorinterface to standardize access to bucket-related properties across resources - Extracted object storage key resolution logic from
ResourceModelinto a standaloneGetObjectStorageKeysfunction - Added helper methods to
BaseModelandResourceModelto implement theBucketAccessorinterface
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| linode/objbucket/framework_models.go | Added RegionOrCluster() and BucketLabel() methods to BaseModel to support BucketAccessor interface |
| linode/objbucket/framework_datasource_schema.go | Reordered schema attributes to group id and label at the top, created at the bottom |
| linode/obj/helpers.go | Updated call to use new standalone GetObjectStorageKeys function |
| linode/obj/framework_resource.go | Renamed method call from GetRegionOrCluster to RegionOrCluster |
| linode/obj/framework_models.go | Removed GetObjectStorageKeys method and added helper methods implementing BucketAccessor interface |
| linode/obj/bucket_accessor.go | Created new file with BucketAccessor interface and GetObjectStorageKeys function for centralized key resolution |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📝 Description
Add
BucketAccessorfor centralized object storage keys logic for the future Framework migration work for the bucket resource.This branch is based on the feature branch of #2235, I will re-target the
devbranch after #2235 being merged.✔️ How to Test
make PKG_NAME="objbucket" test-intmake PKG_NAME="obj" test-int