-
Notifications
You must be signed in to change notification settings - Fork 18.9k
api: move pkg/streamformatter, pkg/progress to daemon/internal
#51153
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
c268cfc to
eab4869
Compare
eab4869 to
4f46ba6
Compare
thaJeztah
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 like we may have some work to do before we can move this internal
| // NewJSONProgressOutput returns a progress.Output that formats output | ||
| // using JSON objects | ||
| func NewJSONProgressOutput(out io.Writer, newLines bool) progress.Output { | ||
| return &progressOutput{sf: &jsonProgressFormatter{}, out: out, newLines: newLines} | ||
| } |
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.
We need to look at this part; the CLI (and I think compose) currently depends on these for the classic builder and for various swarm functions 🫠
https://github.com/docker/cli/blob/6ddff81bee8a46745ce31a01fa7dd4ebaad4e4bd/cli/command/image/build.go#L301
https://github.com/docker/cli/blob/6ddff81bee8a46745ce31a01fa7dd4ebaad4e4bd/cli/command/image/build/context.go#L225-L230
https://github.com/docker/cli/blob/6ddff81bee8a46745ce31a01fa7dd4ebaad4e4bd/cli/command/swarm/progress/root_rotation.go#L31
https://github.com/docker/cli/blob/6ddff81bee8a46745ce31a01fa7dd4ebaad4e4bd/cli/command/service/progress/progress.go#L75
https://github.com/docker/cli/blob/6ddff81bee8a46745ce31a01fa7dd4ebaad4e4bd/cli/command/container/run_test.go#L245
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.
Yes, I had noticed. I don't see what the holdup is in this repo, though. Just make an internal copy of the progress code in those repos when you bump the api dependency, and optionally refactor later to get rid of the silly in-process JSON round trips. You've got to do that for the raw progress formatter regardless.
|
I opened docker/cli#6570 for Docker CLI to make internal copies of streamformatter and progress packages. |
This comment was marked as off-topic.
This comment was marked as off-topic.
|
I opened docker/compose#13304 for Docker compose to have copies there as well. |
|
👎 Having 3 copies of this piece of code (internal + docker/cli + docker/compose) doesn't make the code cleaner |
4f46ba6 to
04f0c73
Compare
|
Okay after discussion with the moby maintainers and feedback from common client PRs (docker/cli#6570 and docker/compose#13304). This change now moves the streamformatter and progress packages up into the client alongside with the internal daemon copy. This is a compromise to have a common shared location outside the API module but the long term location may change. Just for some background for folks, the first release of the client module will be v0.1.0. So this is not a long term commitment for the shape and size of these packages. Ideally long term probably something in CLI or a shared Go SDK. |
Move the streamformatter package up into the client for a temporary shared location between common clients like CLI and compose. The streamformatter package is used by the daemon to write streams of status and progress messages to API clients. It is completely out of scope of the api module and not used outside the daemon. Remove the unused rawSteamFormatter, whose purpose is to render the progress as a TUI. Co-authored-by: Cory Snider <[email protected]> Signed-off-by: Austin Vazquez <[email protected]>
Move the progress package up into the client as a temporary shared location for common clients like CLI and compose. The progress package is used by the daemon to write progress updates to some sink, typically a streamformatter. This package is of little use to API clients as this package does not provide any facilities to consume the progress updates. Co-authored-by: Cory Snider <[email protected]> Signed-off-by: Austin Vazquez <[email protected]>
The schema of a JSON-stream message is very pertinent to the api module. Provide a canonical definition in the api module and refactor the daemon code to use it. Drop the long-deprecated ErrorMessage field from the API definition, but have the daemon continue to emit it for compatibility with docker-py v7.1.0. Co-authored-by: Cory Snider <[email protected]> Signed-off-by: Austin Vazquez <[email protected]>
04f0c73 to
687c3d7
Compare
|
Rebased. PTAL. |
|
@thaJeztah , if you could give this another review; I have addressed the concern and no longer have the packages as internal based on feedback from consumers like compose. Probably we can continue this discussion further to determine the shape and location of the packages long term. |
thaJeztah
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
jsonstream,jsonmessage,progresscleanup #50575- What I did
- How I did it
The aforementioned packages are out of scope for the api module. They provide facilities to write streams of event messages to a sink, but those sinks are either a network socket or a terminal. There is no Engine API endpoint which consumes streams of events from a client, and rendering events to a terminal is out of scope of the api. Move the packages under
daemon/internaland remove dead code.Move the definition of the outer JSON event message to api/types and export it, dropping the deprecated
ErrorMessagefield. Arrange for the daemon to continue to emit that field for compatibility with docker-py v7.1.0.Some of the code in these packages is used by github.com/docker/cli. The removals from the api module may be resolved simply by copying the code into that repository, where it belongs.
What to do with the "github.com/moby/moby/client/pkg/jsonmessage".JSONMessage struct remains to be sorted out. Its
Progressfield is a custom type that knows how to render a progress bar to a terminal; it will not be trivial to refactor it to reference the apijsonstream.Messagetype.api/types/jsonstream#51156- How to verify it
- Human readable description for the release notes
- A picture of a cute animal (not mandatory but encouraged)