-
Notifications
You must be signed in to change notification settings - Fork 18.8k
deprecate pkg/stdcopy, move to api/stdcopy #50462
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
pkg/stdcopy/stdcopy_deprecated.go
Outdated
import ( | ||
"io" | ||
|
||
"github.com/docker/docker/api/stdcopy" |
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.
I was on the fence on the best location for this; it's not a "type" (really?), so it didn't feel right to put it under types/
. Also considered if we needed a utils/
or common/
package underneath api/
.
☝️ input welcome!
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.
Maybe api/internal/stdcopy
, or api/pkg/stdcopy
if internalization is too strict
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.
The tricky bit is that it's used by the client; it's the implementation to decode these multiplexed streams, so it can't be internal.
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.
It's basically the implementation to both produce and handle this format;
Lines 8657 to 8700 in a1ee566
### Stream format | |
When the TTY setting is disabled in [`POST /containers/create`](#operation/ContainerCreate), | |
the HTTP Content-Type header is set to application/vnd.docker.multiplexed-stream | |
and the stream over the hijacked connected is multiplexed to separate out | |
`stdout` and `stderr`. The stream consists of a series of frames, each | |
containing a header and a payload. | |
The header contains the information which the stream writes (`stdout` or | |
`stderr`). It also contains the size of the associated frame encoded in | |
the last four bytes (`uint32`). | |
It is encoded on the first eight bytes like this: | |
```go | |
header := [8]byte{STREAM_TYPE, 0, 0, 0, SIZE1, SIZE2, SIZE3, SIZE4} | |
``` | |
`STREAM_TYPE` can be: | |
- 0: `stdin` (is written on `stdout`) | |
- 1: `stdout` | |
- 2: `stderr` | |
`SIZE1, SIZE2, SIZE3, SIZE4` are the four bytes of the `uint32` size | |
encoded as big endian. | |
Following the header is the payload, which is the specified number of | |
bytes of `STREAM_TYPE`. | |
The simplest way to implement this protocol is the following: | |
1. Read 8 bytes. | |
2. Choose `stdout` or `stderr` depending on the first byte. | |
3. Extract the frame size from the last four bytes. | |
4. Read the extracted size and output it on the correct output. | |
5. Goto 1. | |
### Stream format when using a TTY | |
When the TTY setting is enabled in [`POST /containers/create`](#operation/ContainerCreate), | |
the stream is not multiplexed. The data exchanged over the hijacked | |
connection is simply the raw data from the process PTY and client's | |
`stdin`. |
Derp; need to adjust the validation;
|
The stdcopy package is used to produce and read multiplexed streams for "attach" and "logs". It is used both by the AP 5CC0 I server (to produce), and the client (to read / de-multiplex). Move it to the api package, so that it can be included in the api module. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
The stdcopy package is used to produce and read multiplexed streams for "attach" and "logs". It is used both by the API server (to produce), and the client (to read / de-multiplex).
Move it to the api package, so that it can be included in the api module.
- Human readable description for the release notes
- A picture of a cute animal (not mandatory but encouraged)