Skip to content

Commit 962056e

Browse files
authored
Merge pull request #4534 from thaJeztah/update_engine
vendor: github.com/docker/docker 5b53ddfcdd1c (v25.0.0-dev)
2 parents 16ac0e7 + d40fc1a commit 962056e

37 files changed

Lines changed: 403 additions & 159 deletions

cli/command/checkpoint/client_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,34 @@ package checkpoint
33
import (
44
"context"
55

6-
"github.com/docker/docker/api/types"
6+
"github.com/docker/docker/api/types/checkpoint"
77
"github.com/docker/docker/client"
88
)
99

1010
type fakeClient struct {
1111
client.Client
12-
checkpointCreateFunc func(container string, options types.CheckpointCreateOptions) error
13-
checkpointDeleteFunc func(container string, options types.CheckpointDeleteOptions) error
14-
checkpointListFunc func(container string, options types.CheckpointListOptions) ([]types.Checkpoint, error)
12+
checkpointCreateFunc func(container string, options checkpoint.CreateOptions) error
13+
checkpointDeleteFunc func(container string, options checkpoint.DeleteOptions) error
14+
checkpointListFunc func(container string, options checkpoint.ListOptions) ([]checkpoint.Summary, error)
1515
}
1616

17-
func (cli *fakeClient) CheckpointCreate(_ context.Context, container string, options types.CheckpointCreateOptions) error {
17+
func (cli *fakeClient) CheckpointCreate(_ context.Context, container string, options checkpoint.CreateOptions) error {
1818
if cli.checkpointCreateFunc != nil {
1919
return cli.checkpointCreateFunc(container, options)
2020
}
2121
return nil
2222
}
2323

24-
func (cli *fakeClient) CheckpointDelete(_ context.Context, container string, options types.CheckpointDeleteOptions) error {
24+
func (cli *fakeClient) CheckpointDelete(_ context.Context, container string, options checkpoint.DeleteOptions) error {
2525
if cli.checkpointDeleteFunc != nil {
2626
return cli.checkpointDeleteFunc(container, options)
2727
}
2828
return nil
2929
}
3030

31-
func (cli *fakeClient) CheckpointList(_ context.Context, container string, options types.CheckpointListOptions) ([]types.Checkpoint, error) {
31+
func (cli *fakeClient) CheckpointList(_ context.Context, container string, options checkpoint.ListOptions) ([]checkpoint.Summary, error) {
3232
if cli.checkpointListFunc != nil {
3333
return cli.checkpointListFunc(container, options)
3434
}
35-
return []types.Checkpoint{}, nil
35+
return []checkpoint.Summary{}, nil
3636
}

cli/command/checkpoint/create.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"github.com/docker/cli/cli"
88
"github.com/docker/cli/cli/command"
99
"github.com/docker/cli/cli/command/completion"
10-
"github.com/docker/docker/api/types"
10+
"github.com/docker/docker/api/types/checkpoint"
1111
"github.com/spf13/cobra"
1212
)
1313

@@ -41,15 +41,11 @@ func newCreateCommand(dockerCli command.Cli) *cobra.Command {
4141
}
4242

4343
func runCreate(dockerCli command.Cli, opts createOptions) error {
44-
client := dockerCli.Client()
45-
46-
checkpointOpts := types.CheckpointCreateOptions{
44+
err := dockerCli.Client().CheckpointCreate(context.Background(), opts.container, checkpoint.CreateOptions{
4745
CheckpointID: opts.checkpoint,
4846
CheckpointDir: opts.checkpointDir,
4947
Exit: !opts.leaveRunning,
50-
}
51-
52-
err := client.CheckpointCreate(context.Background(), opts.container, checkpointOpts)
48+
})
5349
if err != nil {
5450
return err
5551
}

cli/command/checkpoint/create_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"testing"
77

88
"github.com/docker/cli/internal/test"
9-
"github.com/docker/docker/api/types"
9+
"github.com/docker/docker/api/types/checkpoint"
1010
"github.com/pkg/errors"
1111
"gotest.tools/v3/assert"
1212
is "gotest.tools/v3/assert/cmp"
@@ -15,7 +15,7 @@ import (
1515
func TestCheckpointCreateErrors(t *testing.T) {
1616
testCases := []struct {
1717
args []string
18-
checkpointCreateFunc func(container string, options types.CheckpointCreateOptions) error
18+
checkpointCreateFunc func(container string, options checkpoint.CreateOptions) error
1919
expectedError string
2020
}{
2121
{
@@ -28,7 +28,7 @@ func TestCheckpointCreateErrors(t *testing.T) {
2828
},
2929
{
3030
args: []string{"foo", "bar"},
31-
checkpointCreateFunc: func(container string, options types.CheckpointCreateOptions) error {
31+
checkpointCreateFunc: func(container string, options checkpoint.CreateOptions) error {
3232
return errors.Errorf("error creating checkpoint for container foo")
3333
},
3434
expectedError: "error creating checkpoint for container foo",
@@ -50,7 +50,7 @@ func TestCheckpointCreateWithOptions(t *testing.T) {
5050
var containerID, checkpointID, checkpointDir string
5151
var exit bool
5252
cli := test.NewFakeCli(&fakeClient{
53-
checkpointCreateFunc: func(container string, options types.CheckpointCreateOptions) error {
53+
checkpointCreateFunc: func(container string, options checkpoint.CreateOptions) error {
5454
containerID = container
5555
checkpointID = options.CheckpointID
5656
checkpointDir = options.CheckpointDir
@@ -59,14 +59,14 @@ func TestCheckpointCreateWithOptions(t *testing.T) {
5959
},
6060
})
6161
cmd := newCreateCommand(cli)
62-
checkpoint := "checkpoint-bar"
63-
cmd.SetArgs([]string{"container-foo", checkpoint})
62+
cp := "checkpoint-bar"
63+
cmd.SetArgs([]string{"container-foo", cp})
6464
cmd.Flags().Set("leave-running", "true")
6565
cmd.Flags().Set("checkpoint-dir", "/dir/foo")
6666
assert.NilError(t, cmd.Execute())
6767
assert.Check(t, is.Equal("container-foo", containerID))
68-
assert.Check(t, is.Equal(checkpoint, checkpointID))
68+
assert.Check(t, is.Equal(cp, checkpointID))
6969
assert.Check(t, is.Equal("/dir/foo", checkpointDir))
7070
assert.Check(t, is.Equal(false, exit))
71-
assert.Check(t, is.Equal(checkpoint, strings.TrimSpace(cli.OutBuffer().String())))
71+
assert.Check(t, is.Equal(cp, strings.TrimSpace(cli.OutBuffer().String())))
7272
}

cli/command/checkpoint/formatter.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@ package checkpoint
22

33
import (
44
"github.com/docker/cli/cli/command/formatter"
5-
"github.com/docker/docker/api/types"
5+
"github.com/docker/docker/api/types/checkpoint"
66
)
77

88
const (
99
defaultCheckpointFormat = "table {{.Name}}"
10-
11-
checkpointNameHeader = "CHECKPOINT NAME"
10+
checkpointNameHeader = "CHECKPOINT NAME"
1211
)
1312

1413
// NewFormat returns a format for use with a checkpoint Context
@@ -21,10 +20,10 @@ func NewFormat(source string) formatter.Format {
2120
}
2221

2322
// FormatWrite writes formatted checkpoints using the Context
24-
func FormatWrite(ctx formatter.Context, checkpoints []types.Checkpoint) error {
23+
func FormatWrite(ctx formatter.Context, checkpoints []checkpoint.Summary) error {
2524
render := func(format func(subContext formatter.SubContext) error) error {
26-
for _, checkpoint := range checkpoints {
27-
if err := format(&checkpointContext{c: checkpoint}); err != nil {
25+
for _, cp := range checkpoints {
26+
if err := format(&checkpointContext{c: cp}); err != nil {
2827
return err
2928
}
3029
}
@@ -35,7 +34,7 @@ func FormatWrite(ctx formatter.Context, checkpoints []types.Checkpoint) error {
3534

3635
type checkpointContext struct {
3736
formatter.HeaderContext
38-
c types.Checkpoint
37+
c checkpoint.Summary
3938
}
4039

4140
func newCheckpointContext() *checkpointContext {

cli/command/checkpoint/formatter_test.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"testing"
66

77
"github.com/docker/cli/cli/command/formatter"
8-
"github.com/docker/docker/api/types"
8+
"github.com/docker/docker/api/types/checkpoint"
99
"gotest.tools/v3/assert"
1010
)
1111

@@ -38,15 +38,14 @@ checkpoint-3:
3838
},
3939
}
4040

41-
checkpoints := []types.Checkpoint{
42-
{Name: "checkpoint-1"},
43-
{Name: "checkpoint-2"},
44-
{Name: "checkpoint-3"},
45-
}
4641
for _, testcase := range cases {
4742
out := bytes.NewBufferString("")
4843
testcase.context.Output = out
49-
err := FormatWrite(testcase.context, checkpoints)
44+
err := FormatWrite(testcase.context, []checkpoint.Summary{
45+
{Name: "checkpoint-1"},
46+
{Name: "checkpoint-2"},
47+
{Name: "checkpoint-3"},
48+
})
5049
assert.NilError(t, err)
5150
assert.Equal(t, out.String(), testcase.expected)
5251
}

cli/command/checkpoint/list.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"github.com/docker/cli/cli/command"
88
"github.com/docker/cli/cli/command/completion"
99
"github.com/docker/cli/cli/command/formatter"
10-
"github.com/docker/docker/api/types"
10+
"github.com/docker/docker/api/types/checkpoint"
1111
"github.com/spf13/cobra"
1212
)
1313

@@ -36,13 +36,9 @@ func newListCommand(dockerCli command.Cli) *cobra.Command {
3636
}
3737

3838
func runList(dockerCli command.Cli, container string, opts listOptions) error {
39-
client := dockerCli.Client()
40-
41-
listOpts := types.CheckpointListOptions{
39+
checkpoints, err := dockerCli.Client().CheckpointList(context.Background(), container, checkpoint.ListOptions{
4240
CheckpointDir: opts.checkpointDir,
43-
}
44-
45-
checkpoints, err := client.CheckpointList(context.Background(), container, listOpts)
41+
})
4642
if err != nil {
4743
return err
4844
}

cli/command/checkpoint/list_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"testing"
66

77
"github.com/docker/cli/internal/test"
8-
"github.com/docker/docker/api/types"
8+
"github.com/docker/docker/api/types/checkpoint"
99
"github.com/pkg/errors"
1010
"gotest.tools/v3/assert"
1111
is "gotest.tools/v3/assert/cmp"
@@ -15,7 +15,7 @@ import (
1515
func TestCheckpointListErrors(t *testing.T) {
1616
testCases := []struct {
1717
args []string
18-
checkpointListFunc func(container string, options types.CheckpointListOptions) ([]types.Checkpoint, error)
18+
checkpointListFunc func(container string, options checkpoint.ListOptions) ([]checkpoint.Summary, error)
1919
expectedError string
2020
}{
2121
{
@@ -28,8 +28,8 @@ func TestCheckpointListErrors(t *testing.T) {
2828
},
2929
{
3030
args: []string{"foo"},
31-
checkpointListFunc: func(container string, options types.CheckpointListOptions) ([]types.Checkpoint, error) {
32-
return []types.Checkpoint{}, errors.Errorf("error getting checkpoints for container foo")
31+
checkpointListFunc: func(container string, options checkpoint.ListOptions) ([]checkpoint.Summary, error) {
32+
return []checkpoint.Summary{}, errors.Errorf("error getting checkpoints for container foo")
3333
},
3434
expectedError: "error getting checkpoints for container foo",
3535
},
@@ -49,10 +49,10 @@ func TestCheckpointListErrors(t *testing.T) {
4949
func TestCheckpointListWithOptions(t *testing.T) {
5050
var containerID, checkpointDir string
5151
cli := test.NewFakeCli(&fakeClient{
52-
checkpointListFunc: func(container string, options types.CheckpointListOptions) ([]types.Checkpoint, error) {
52+
checkpointListFunc: func(container string, options checkpoint.ListOptions) ([]checkpoint.Summary, error) {
5353
containerID = container
5454
checkpointDir = options.CheckpointDir
55-
return []types.Checkpoint{
55+
return []checkpoint.Summary{
5656
{Name: "checkpoint-foo"},
5757
}, nil
5858
},

cli/command/checkpoint/remove.go

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55

66
"github.com/docker/cli/cli"
77
"github.com/docker/cli/cli/command"
8-
"github.com/docker/docker/api/types"
8+
"github.com/docker/docker/api/types/checkpoint"
99
"github.com/spf13/cobra"
1010
)
1111

@@ -32,13 +32,9 @@ func newRemoveCommand(dockerCli command.Cli) *cobra.Command {
3232
return cmd
3333
}
3434

35-
func runRemove(dockerCli command.Cli, container string, checkpoint string, opts removeOptions) error {
36-
client := dockerCli.Client()
37-
38-
removeOpts := types.CheckpointDeleteOptions{
39-
CheckpointID: checkpoint,
35+
func runRemove(dockerCli command.Cli, container string, checkpointID string, opts removeOptions) error {
36+
return dockerCli.Client().CheckpointDelete(context.Background(), container, checkpoint.DeleteOptions{
37+
CheckpointID: checkpointID,
4038
CheckpointDir: opts.checkpointDir,
41-
}
42-
43-
return client.CheckpointDelete(context.Background(), container, removeOpts)
39+
})
4440
}

cli/command/checkpoint/remove_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"testing"
66

77
"github.com/docker/cli/internal/test"
8-
"github.com/docker/docker/api/types"
8+
"github.com/docker/docker/api/types/checkpoint"
99
"github.com/pkg/errors"
1010
"gotest.tools/v3/assert"
1111
is "gotest.tools/v3/assert/cmp"
@@ -14,7 +14,7 @@ import (
1414
func TestCheckpointRemoveErrors(t *testing.T) {
1515
testCases := []struct {
1616
args []string
17-
checkpointDeleteFunc func(container string, options types.CheckpointDeleteOptions) error
17+
checkpointDeleteFunc func(container string, options checkpoint.DeleteOptions) error
1818
expectedError string
1919
}{
2020
{
@@ -27,7 +27,7 @@ func TestCheckpointRemoveErrors(t *testing.T) {
2727
},
2828
{
2929
args: []string{"foo", "bar"},
30-
checkpointDeleteFunc: func(container string, options types.CheckpointDeleteOptions) error {
30+
checkpointDeleteFunc: func(container string, options checkpoint.DeleteOptions) error {
3131
return errors.Errorf("error deleting checkpoint")
3232
},
3333
expectedError: "error deleting checkpoint",
@@ -48,7 +48,7 @@ func TestCheckpointRemoveErrors(t *testing.T) {
4848
func TestCheckpointRemoveWithOptions(t *testing.T) {
4949
var containerID, checkpointID, checkpointDir string
5050
cli := test.NewFakeCli(&fakeClient{
51-
checkpointDeleteFunc: func(container string, options types.CheckpointDeleteOptions) error {
51+
checkpointDeleteFunc: func(container string, options checkpoint.DeleteOptions) error {
5252
containerID = container
5353
checkpointID = options.CheckpointID
5454
checkpointDir = options.CheckpointDir

cli/command/container/opts.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ func addFlags(flags *pflag.FlagSet) *containerOptions {
185185
flags.VarP(&copts.labels, "label", "l", "Set meta data on a container")
186186
flags.Var(&copts.labelsFile, "label-file", "Read in a line delimited file of labels")
187187
flags.BoolVar(&copts.readonlyRootfs, "read-only", false, "Mount the container's root filesystem as read only")
188-
flags.StringVar(&copts.restartPolicy, "restart", "no", "Restart policy to apply when a container exits")
188+
flags.StringVar(&copts.restartPolicy, "restart", string(container.RestartPolicyDisabled), "Restart policy to apply when a container exits")
189189
flags.StringVar(&copts.stopSignal, "stop-signal", "", "Signal to stop the container")
190190
flags.IntVar(&copts.stopTimeout, "stop-timeout", 0, "Timeout (in seconds) to stop a container")
191191
flags.SetAnnotation("stop-timeout", "version", []string{"1.25"})

0 commit comments

Comments
 (0)