mirror of
https://github.com/moby/moby.git
synced 2026-01-11 02:31:44 +00:00
Add option- and output structs for; - Client.ContainerKill - Client.ContainerPause - Client.ContainerRemove - Client.ContainerResize - Client.ContainerRestart - Client.ContainerStart - Client.ContainerStop - Client.ContainerUnpause Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
41 lines
1.0 KiB
Go
41 lines
1.0 KiB
Go
package client
|
|
|
|
import (
|
|
"context"
|
|
"net/url"
|
|
)
|
|
|
|
// ContainerStartOptions holds options for [Client.ContainerStart].
|
|
type ContainerStartOptions struct {
|
|
CheckpointID string
|
|
CheckpointDir string
|
|
}
|
|
|
|
// ContainerStartResult holds the result of [Client.ContainerStart],
|
|
type ContainerStartResult struct {
|
|
// Add future fields here.
|
|
}
|
|
|
|
// ContainerStart sends a request to the docker daemon to start a container.
|
|
func (cli *Client) ContainerStart(ctx context.Context, containerID string, options ContainerStartOptions) (ContainerStartResult, error) {
|
|
containerID, err := trimID("container", containerID)
|
|
if err != nil {
|
|
return ContainerStartResult{}, err
|
|
}
|
|
|
|
query := url.Values{}
|
|
if options.CheckpointID != "" {
|
|
query.Set("checkpoint", options.CheckpointID)
|
|
}
|
|
if options.CheckpointDir != "" {
|
|
query.Set("checkpoint-dir", options.CheckpointDir)
|
|
}
|
|
|
|
resp, err := cli.post(ctx, "/containers/"+containerID+"/start", query, nil, nil)
|
|
defer ensureReaderClosed(resp)
|
|
if err != nil {
|
|
return ContainerStartResult{}, err
|
|
}
|
|
return ContainerStartResult{}, nil
|
|
}
|