refactor(api): extract domain types to internal/types#1412
Open
Moustafa-Moustafa wants to merge 1 commit into
Open
refactor(api): extract domain types to internal/types#1412Moustafa-Moustafa wants to merge 1 commit into
Moustafa-Moustafa wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Refactors backend/pkg/api by extracting shared domain structs/constants into the new internal package backend/pkg/api/internal/types, while keeping pkg/api as a compatibility layer via type/const re-exports so external callers don’t need to change yet.
Changes:
- Introduces
backend/pkg/api/internal/typescontaining API domain types (e.g., User/Team/Package/Group/Instance/Arch/etc.). - Replaces in-package struct definitions with
type X = types.Xaliases and re-exports some constants. - Moves architecture parsing/formatting logic into the internal types package and re-exports it from
pkg/api.
Reviewed changes
Copilot reviewed 26 out of 26 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| backend/pkg/api/api.go | Removes ErrInvalidArch from this file as arch concerns move to the extracted types layer. |
| backend/pkg/api/activity.go | Re-exports Activity and ActivityQueryParams from internal/types. |
| backend/pkg/api/actions.go | Re-exports FlatcarAction from internal/types. |
| backend/pkg/api/applications.go | Re-exports Application from internal/types. |
| backend/pkg/api/arch.go | Re-exports Arch, arch constants, and arch helpers from internal/types. |
| backend/pkg/api/channels.go | Re-exports Channel from internal/types. |
| backend/pkg/api/groups.go | Re-exports group-related domain types from internal/types. |
| backend/pkg/api/instances.go | Re-exports instance domain types and status constants from internal/types. |
| backend/pkg/api/metrics.go | Re-exports metric result structs from internal/types. |
| backend/pkg/api/packages.go | Re-exports package-related types (Package/File/etc.) from internal/types. |
| backend/pkg/api/packages_floors.go | Re-exports ChannelFloorInfo from internal/types. |
| backend/pkg/api/teams.go | Re-exports Team from internal/types. |
| backend/pkg/api/users.go | Re-exports User from internal/types. |
| backend/pkg/api/internal/types/action.go | Adds FlatcarAction definition to the internal types package. |
| backend/pkg/api/internal/types/activity.go | Adds Activity and ActivityQueryParams definitions to the internal types package. |
| backend/pkg/api/internal/types/application.go | Adds Application definition to the internal types package. |
| backend/pkg/api/internal/types/arch.go | Adds Arch type, constants, and parsing/formatting helpers to the internal types package. |
| backend/pkg/api/internal/types/channel.go | Adds Channel definition to the internal types package. |
| backend/pkg/api/internal/types/channel_floor.go | Adds ChannelFloorInfo definition to the internal types package. |
| backend/pkg/api/internal/types/group.go | Adds Group and related group domain types to the internal types package. |
| backend/pkg/api/internal/types/instance.go | Adds Instance and related instance domain types/status constants to the internal types package. |
| backend/pkg/api/internal/types/metrics.go | Adds metric result structs to the internal types package. |
| backend/pkg/api/internal/types/package.go | Adds Package, File, and ChannelPackageFloor definitions to the internal types package. |
| backend/pkg/api/internal/types/string_array.go | Moves StringArray implementation into the internal types package. |
| backend/pkg/api/internal/types/team.go | Adds Team definition to the internal types package. |
| backend/pkg/api/internal/types/user.go | Adds User definition to the internal types package. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
e4ca6ce to
ba11ba2
Compare
Move pkg/api data types and their methods into a new internal package pkg/api/internal/types. pkg/api keeps re-exports (type X = types.X, const/var re-exports) so callers stay unchanged. The re-exports let us minimize the size of the change and avoid updating any tests in this commit. Eventually, after splitting into the 3 packages (dbreads, admin, runtime), we will drop the re-exports in the api package and callers can reference the types package directly. Prerequisite for extracting the read layer into pkg/api/internal/dbreads, which is itself a step towards later splitting the admin and runtime writer packages. dbreads cannot import pkg/api without an import cycle, so shared types have to live in a neutral internal package first. This commit is purely refactoring and shouldn't change any behavior. Refs: flatcar#1375 Signed-off-by: Moustafa Moustafa <momousta@microsoft.com>
ba11ba2 to
0575f0b
Compare
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.
refactor(api): extract domain types to
pkg/api/internal/typesGroundwork for the sub-package split described in RFC #1375 (Rollout PR 3: extract
pkg/api/dbreads/). See also the design doc in #1405.Move pkg/api data types and their methods into a new internal package pkg/api/internal/types. pkg/api keeps re-exports (type X = types.X, const/var re-exports) so callers stay unchanged. The re-exports let us minimize the size of the change and avoid updating any tests in this commit. Eventually, after splitting into the 3 packages (dbreads, admin, runtime), we will drop the re-exports in the api package and callers can reference the types package directly.
Prerequisite for extracting the read layer into pkg/api/internal/dbreads, which is itself a step towards later splitting the admin and runtime writer packages. dbreads cannot import pkg/api without an import cycle, so shared types have to live in a neutral internal package first.
This commit is purely refactoring and shouldn't change any behavior.
After the follow-up dbreads-extraction PR
flowchart TD handler[pkg/handler] omaha[pkg/omaha] syncer[pkg/syncer] api[pkg/api<br/>writers + shims] dbreads[pkg/api/internal/dbreads<br/>read queries] types[pkg/api/internal/types<br/>domain types] handler --> api omaha --> api syncer --> api api --> dbreads api --> types dbreads --> typesHow to use
Testing done
Additionally, a manual end-to-end scenario suite was run against the local container.
changelog/directory (user-facing change, bug fix, security fix, update)/bootand/usrsize, packages, list files for any missing binaries, kernel modules, config files, kernel modules, etc.