Repository navigation
refactor(api): split Compose into focused interfaces - #14322
Merged
Merged
Conversation
Compose is now composed by embedding Lifecycle, Inspector, ImageManager, Runner, Watcher and ProjectLoader. The method set of Compose is unchanged. ProjectOptions.ToProject and configOptions.ToProject only need to load a project, so they now depend on api.ProjectLoader. Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
docker-agent
left a comment
Contributor
There was a problem hiding this comment.
Assessment: 🟢 APPROVE
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
3 tasks
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.
What this PR does, in one sentence
Splits the 30-odd-method
api.Composeinterface into six small interfaces by responsibility and rebuildsComposeby embedding them, without changing its method set.Context
api.Composeis a god interface: every command added to Compose touches it, its generated mock and the docs, and every consumer (thecmd/composecommands, SDK users) depends on the whole surface even when it calls one or two methods. Tests that need a backend end up with the full mock, and nothing in a function signature tells the reader what it actually needs from the backend.What the PR brings
Composeis nowLifecycle+Inspector+ImageManager+Runner+Watcher+ProjectLoader:Lifecycle: Create, Start, Restart, Stop, Up, Down, Kill, Pause, UnPause, Scale, Remove, WaitInspector(read-only): Ps, List, Top, Ports, Images, Volumes, Events, Logs, VizImageManager: Build, Push, Pull, PublishRunner: RunOneOffContainer, Exec, Attach, Copy, Export, CommitWatcher: WatchProjectLoader: LoadProject, GenerateThe guardrails: the method set of
Composeis strictly identical, with every doc comment kept, so SDK users andcomposeServiceare unaffected. The mocks are regenerated with the pinned mockgen;MockComposeis unchanged and a mock per narrow interface is added. No behavior change.As a first illustration, the two
ToProjecthelpers incmd/compose, which only ever callLoadProject, now take anapi.ProjectLoader. No other consumer is migrated here.Why this is the right first brick
It is purely additive and inert, so it is easy to review. It also makes the follow-up mechanical: narrow the
cmd/composedependencies one command at a time to the sub-interface they use, with correspondingly small test doubles, without ever touching the publicComposecontract.🤖 Generated with Claude Code