-
Notifications
You must be signed in to change notification settings - Fork 18.9k
Expand file tree
/
Copy pathcheckpoint_create.go
More file actions
36 lines (30 loc) · 1.04 KB
/
checkpoint_create.go
File metadata and controls
36 lines (30 loc) · 1.04 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
package client
import (
"context"
"github.com/moby/moby/api/types/checkpoint"
)
// CheckpointCreateOptions holds parameters to create a checkpoint from a container.
type CheckpointCreateOptions struct {
CheckpointID string
CheckpointDir string
Exit bool
}
// CheckpointCreateResult holds the result from [client.CheckpointCreate].
type CheckpointCreateResult struct {
// Add future fields here
}
// CheckpointCreate creates a checkpoint from the given container.
func (cli *Client) CheckpointCreate(ctx context.Context, containerID string, options CheckpointCreateOptions) (CheckpointCreateResult, error) {
containerID, err := trimID("container", containerID)
if err != nil {
return CheckpointCreateResult{}, err
}
requestBody := checkpoint.CreateRequest{
CheckpointID: options.CheckpointID,
CheckpointDir: options.CheckpointDir,
Exit: options.Exit,
}
resp, err := cli.post(ctx, "/containers/"+containerID+"/checkpoints", nil, requestBody, nil)
defer ensureReaderClosed(resp)
return CheckpointCreateResult{}, err
}