api/types: move ResizeOptions to api/types/container
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
ec69501e94
commit
95b92b1f97
8 changed files with 32 additions and 23 deletions
|
@ -289,14 +289,6 @@ type ImageSearchOptions struct {
|
|||
Limit int
|
||||
}
|
||||
|
||||
// ResizeOptions holds parameters to resize a tty.
|
||||
// It can be used to resize container ttys and
|
||||
// exec process ttys too.
|
||||
type ResizeOptions struct {
|
||||
Height uint
|
||||
Width uint
|
||||
}
|
||||
|
||||
// NodeListOptions holds parameters to list nodes with.
|
||||
type NodeListOptions struct {
|
||||
Filters filters.Args
|
||||
|
|
9
api/types/container/options.go
Normal file
9
api/types/container/options.go
Normal file
|
@ -0,0 +1,9 @@
|
|||
package container
|
||||
|
||||
// ResizeOptions holds parameters to resize a TTY.
|
||||
// It can be used to resize container TTYs and
|
||||
// exec process TTYs too.
|
||||
type ResizeOptions struct {
|
||||
Height uint
|
||||
Width uint
|
||||
}
|
|
@ -2,6 +2,7 @@ package types
|
|||
|
||||
import (
|
||||
"github.com/docker/docker/api/types/checkpoint"
|
||||
"github.com/docker/docker/api/types/container"
|
||||
"github.com/docker/docker/api/types/image"
|
||||
"github.com/docker/docker/api/types/swarm"
|
||||
"github.com/docker/docker/api/types/system"
|
||||
|
@ -91,6 +92,13 @@ type ServiceCreateResponse = swarm.ServiceCreateResponse
|
|||
// Deprecated: use [swarm.ServiceUpdateResponse].
|
||||
type ServiceUpdateResponse = swarm.ServiceUpdateResponse
|
||||
|
||||
// ResizeOptions holds parameters to resize a TTY.
|
||||
// It can be used to resize container TTYs and
|
||||
// exec process TTYs too.
|
||||
//
|
||||
// Deprecated: use [container.ResizeOptions].
|
||||
type ResizeOptions = container.ResizeOptions
|
||||
|
||||
// DecodeSecurityOptions decodes a security options string slice to a type safe
|
||||
// [system.SecurityOpt].
|
||||
//
|
||||
|
|
|
@ -5,16 +5,16 @@ import (
|
|||
"net/url"
|
||||
"strconv"
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/container"
|
||||
)
|
||||
|
||||
// ContainerResize changes the size of the tty for a container.
|
||||
func (cli *Client) ContainerResize(ctx context.Context, containerID string, options types.ResizeOptions) error {
|
||||
func (cli *Client) ContainerResize(ctx context.Context, containerID string, options container.ResizeOptions) error {
|
||||
return cli.resize(ctx, "/containers/"+containerID, options.Height, options.Width)
|
||||
}
|
||||
|
||||
// ContainerExecResize changes the size of the tty for an exec process running inside a container.
|
||||
func (cli *Client) ContainerExecResize(ctx context.Context, execID string, options types.ResizeOptions) error {
|
||||
func (cli *Client) ContainerExecResize(ctx context.Context, execID string, options container.ResizeOptions) error {
|
||||
return cli.resize(ctx, "/exec/"+execID, options.Height, options.Width)
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ import (
|
|||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/container"
|
||||
"github.com/docker/docker/errdefs"
|
||||
"gotest.tools/v3/assert"
|
||||
is "gotest.tools/v3/assert/cmp"
|
||||
|
@ -19,7 +19,7 @@ func TestContainerResizeError(t *testing.T) {
|
|||
client := &Client{
|
||||
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
|
||||
}
|
||||
err := client.ContainerResize(context.Background(), "container_id", types.ResizeOptions{})
|
||||
err := client.ContainerResize(context.Background(), "container_id", container.ResizeOptions{})
|
||||
assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ func TestContainerExecResizeError(t *testing.T) {
|
|||
client := &Client{
|
||||
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
|
||||
}
|
||||
err := client.ContainerExecResize(context.Background(), "exec_id", types.ResizeOptions{})
|
||||
err := client.ContainerExecResize(context.Background(), "exec_id", container.ResizeOptions{})
|
||||
assert.Check(t, is.ErrorType(err, errdefs.IsSystem))
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ func TestContainerResize(t *testing.T) {
|
|||
client: newMockClient(resizeTransport("/containers/container_id/resize")),
|
||||
}
|
||||
|
||||
err := client.ContainerResize(context.Background(), "container_id", types.ResizeOptions{
|
||||
err := client.ContainerResize(context.Background(), "container_id", container.ResizeOptions{
|
||||
Height: 500,
|
||||
Width: 600,
|
||||
})
|
||||
|
@ -50,7 +50,7 @@ func TestContainerExecResize(t *testing.T) {
|
|||
client: newMockClient(resizeTransport("/exec/exec_id/resize")),
|
||||
}
|
||||
|
||||
err := client.ContainerExecResize(context.Background(), "exec_id", types.ResizeOptions{
|
||||
err := client.ContainerExecResize(context.Background(), "exec_id", container.ResizeOptions{
|
||||
Height: 500,
|
||||
Width: 600,
|
||||
})
|
||||
|
|
|
@ -53,7 +53,7 @@ type ContainerAPIClient interface {
|
|||
ContainerExecAttach(ctx context.Context, execID string, config types.ExecStartCheck) (types.HijackedResponse, error)
|
||||
ContainerExecCreate(ctx context.Context, container string, config types.ExecConfig) (types.IDResponse, error)
|
||||
ContainerExecInspect(ctx context.Context, execID string) (types.ContainerExecInspect, error)
|
||||
ContainerExecResize(ctx context.Context, execID string, options types.ResizeOptions) error
|
||||
ContainerExecResize(ctx context.Context, execID string, options container.ResizeOptions) error
|
||||
ContainerExecStart(ctx context.Context, execID string, config types.ExecStartCheck) error
|
||||
ContainerExport(ctx context.Context, container string) (io.ReadCloser, error)
|
||||
ContainerInspect(ctx context.Context, container string) (types.ContainerJSON, error)
|
||||
|
@ -64,7 +64,7 @@ type ContainerAPIClient interface {
|
|||
ContainerPause(ctx context.Context, container string) error
|
||||
ContainerRemove(ctx context.Context, container string, options types.ContainerRemoveOptions) error
|
||||
ContainerRename(ctx context.Context, container, newContainerName string) error
|
||||
ContainerResize(ctx context.Context, container string, options types.ResizeOptions) error
|
||||
ContainerResize(ctx context.Context, container string, options container.ResizeOptions) error
|
||||
ContainerRestart(ctx context.Context, container string, options container.StopOptions) error
|
||||
ContainerStatPath(ctx context.Context, container, path string) (types.ContainerPathStat, error)
|
||||
ContainerStats(ctx context.Context, container string, stream bool) (types.ContainerStats, error)
|
||||
|
|
|
@ -13,7 +13,7 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
"github.com/docker/docker/api/types/container"
|
||||
eventtypes "github.com/docker/docker/api/types/events"
|
||||
"github.com/docker/docker/client"
|
||||
eventstestutils "github.com/docker/docker/daemon/events/testutils"
|
||||
|
@ -459,7 +459,7 @@ func (s *DockerCLIEventSuite) TestEventsResize(c *testing.T) {
|
|||
assert.NilError(c, err)
|
||||
defer apiClient.Close()
|
||||
|
||||
options := types.ResizeOptions{
|
||||
options := container.ResizeOptions{
|
||||
Height: 80,
|
||||
Width: 24,
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"net/http"
|
||||
"testing"
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
containertypes "github.com/docker/docker/api/types/container"
|
||||
"github.com/docker/docker/api/types/versions"
|
||||
"github.com/docker/docker/errdefs"
|
||||
"github.com/docker/docker/integration/internal/container"
|
||||
|
@ -20,7 +20,7 @@ func TestResize(t *testing.T) {
|
|||
|
||||
t.Run("success", func(t *testing.T) {
|
||||
cID := container.Run(ctx, t, apiClient, container.WithTty(true))
|
||||
err := apiClient.ContainerResize(ctx, cID, types.ResizeOptions{
|
||||
err := apiClient.ContainerResize(ctx, cID, containertypes.ResizeOptions{
|
||||
Height: 40,
|
||||
Width: 40,
|
||||
})
|
||||
|
@ -46,7 +46,7 @@ func TestResize(t *testing.T) {
|
|||
|
||||
t.Run("invalid state", func(t *testing.T) {
|
||||
cID := container.Create(ctx, t, apiClient, container.WithCmd("echo"))
|
||||
err := apiClient.ContainerResize(ctx, cID, types.ResizeOptions{
|
||||
err := apiClient.ContainerResize(ctx, cID, containertypes.ResizeOptions{
|
||||
Height: 40,
|
||||
Width: 40,
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue