-
Notifications
You must be signed in to change notification settings - Fork 18.9k
Expand file tree
/
Copy pathcontainer_export.go
More file actions
47 lines (39 loc) · 1.2 KB
/
container_export.go
File metadata and controls
47 lines (39 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package client
import (
"context"
"io"
"net/url"
)
// ContainerExportOptions specifies options for container export operations.
type ContainerExportOptions struct {
// Currently no options are defined for ContainerExport
}
// ContainerExportResult represents the result of a container export operation.
type ContainerExportResult interface {
io.ReadCloser
}
// ContainerExport retrieves the raw contents of a container
// and returns them as an [io.ReadCloser]. It's up to the caller
// to close the stream.
//
// The underlying [io.ReadCloser] is automatically closed if the context is canceled,
func (cli *Client) ContainerExport(ctx context.Context, containerID string, options ContainerExportOptions) (ContainerExportResult, error) {
containerID, err := trimID("container", containerID)
if err != nil {
return nil, err
}
resp, err := cli.get(ctx, "/containers/"+containerID+"/export", url.Values{}, nil)
if err != nil {
return nil, err
}
return &containerExportResult{
ReadCloser: newCancelReadCloser(ctx, resp.Body),
}, nil
}
type containerExportResult struct {
io.ReadCloser
}
var (
_ io.ReadCloser = (*containerExportResult)(nil)
_ ContainerExportResult = (*containerExportResult)(nil)
)