Skip to content

Commit 3469beb

Browse files
committed
replace uses of deprecated api/types that moved to api/types/system
These types were moved to api/types/system: - types.Info - types.Commit - types.PluginsInfo - types.NetworkAddressPool - types.Runtime - types.SecurityOpt - types/KeyValue - types.DecodeSecurityOptions() Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent 1f87420 commit 3469beb

22 files changed

Lines changed: 122 additions & 111 deletions

cli/command/container/client_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"github.com/docker/docker/api/types"
88
"github.com/docker/docker/api/types/container"
99
"github.com/docker/docker/api/types/network"
10+
"github.com/docker/docker/api/types/system"
1011
"github.com/docker/docker/client"
1112
specs "github.com/opencontainers/image-spec/specs-go/v1"
1213
)
@@ -23,7 +24,7 @@ type fakeClient struct {
2324
containerName string) (container.CreateResponse, error)
2425
containerStartFunc func(container string, options types.ContainerStartOptions) error
2526
imageCreateFunc func(parentReference string, options types.ImageCreateOptions) (io.ReadCloser, error)
26-
infoFunc func() (types.Info, error)
27+
infoFunc func() (system.Info, error)
2728
containerStatPathFunc func(container, path string) (types.ContainerPathStat, error)
2829
containerCopyFromFunc func(container, srcPath string) (io.ReadCloser, types.ContainerPathStat, error)
2930
logFunc func(string, types.ContainerLogsOptions) (io.ReadCloser, error)
@@ -96,11 +97,11 @@ func (f *fakeClient) ImageCreate(_ context.Context, parentReference string, opti
9697
return nil, nil
9798
}
9899

99-
func (f *fakeClient) Info(_ context.Context) (types.Info, error) {
100+
func (f *fakeClient) Info(_ context.Context) (system.Info, error) {
100101
if f.infoFunc != nil {
101102
return f.infoFunc()
102103
}
103-
return types.Info{}, nil
104+
return system.Info{}, nil
104105
}
105106

106107
func (f *fakeClient) ContainerStatPath(_ context.Context, container, path string) (types.ContainerPathStat, error) {

cli/command/container/create_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"github.com/docker/docker/api/types"
1919
"github.com/docker/docker/api/types/container"
2020
"github.com/docker/docker/api/types/network"
21+
"github.com/docker/docker/api/types/system"
2122
"github.com/google/go-cmp/cmp"
2223
specs "github.com/opencontainers/image-spec/specs-go/v1"
2324
"github.com/spf13/pflag"
@@ -137,8 +138,8 @@ func TestCreateContainerImagePullPolicy(t *testing.T) {
137138
defer func() { pullCounter++ }()
138139
return io.NopCloser(strings.NewReader("")), nil
139140
},
140-
infoFunc: func() (types.Info, error) {
141-
return types.Info{IndexServerAddress: "https://indexserver.example.com"}, nil
141+
infoFunc: func() (system.Info, error) {
142+
return system.Info{IndexServerAddress: "https://indexserver.example.com"}, nil
142143
},
143144
}
144145
fakeCLI := test.NewFakeCli(client)

cli/command/image/client_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"github.com/docker/docker/api/types"
1010
"github.com/docker/docker/api/types/filters"
1111
"github.com/docker/docker/api/types/image"
12+
"github.com/docker/docker/api/types/system"
1213
"github.com/docker/docker/client"
1314
)
1415

@@ -18,7 +19,7 @@ type fakeClient struct {
1819
imageSaveFunc func(images []string) (io.ReadCloser, error)
1920
imageRemoveFunc func(image string, options types.ImageRemoveOptions) ([]types.ImageDeleteResponseItem, error)
2021
imagePushFunc func(ref string, options types.ImagePushOptions) (io.ReadCloser, error)
21-
infoFunc func() (types.Info, error)
22+
infoFunc func() (system.Info, error)
2223
imagePullFunc func(ref string, options types.ImagePullOptions) (io.ReadCloser, error)
2324
imagesPruneFunc func(pruneFilter filters.Args) (types.ImagesPruneReport, error)
2425
imageLoadFunc func(input io.Reader, quiet bool) (types.ImageLoadResponse, error)
@@ -59,11 +60,11 @@ func (cli *fakeClient) ImagePush(_ context.Context, ref string, options types.Im
5960
return io.NopCloser(strings.NewReader("")), nil
6061
}
6162

62-
func (cli *fakeClient) Info(_ context.Context) (types.Info, error) {
63+
func (cli *fakeClient) Info(_ context.Context) (system.Info, error) {
6364
if cli.infoFunc != nil {
6465
return cli.infoFunc()
6566
}
66-
return types.Info{}, nil
67+
return system.Info{}, nil
6768
}
6869

6970
func (cli *fakeClient) ImagePull(_ context.Context, ref string, options types.ImagePullOptions) (io.ReadCloser, error) {

cli/command/node/client_test.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ import (
55

66
"github.com/docker/docker/api/types"
77
"github.com/docker/docker/api/types/swarm"
8+
"github.com/docker/docker/api/types/system"
89
"github.com/docker/docker/client"
910
)
1011

1112
type fakeClient struct {
1213
client.Client
13-
infoFunc func() (types.Info, error)
14+
infoFunc func() (system.Info, error)
1415
nodeInspectFunc func() (swarm.Node, []byte, error)
1516
nodeListFunc func() ([]swarm.Node, error)
1617
nodeRemoveFunc func() error
@@ -48,11 +49,11 @@ func (cli *fakeClient) NodeUpdate(_ context.Context, nodeID string, version swar
4849
return nil
4950
}
5051

51-
func (cli *fakeClient) Info(context.Context) (types.Info, error) {
52+
func (cli *fakeClient) Info(context.Context) (system.Info, error) {
5253
if cli.infoFunc != nil {
5354
return cli.infoFunc()
5455
}
55-
return types.Info{}, nil
56+
return system.Info{}, nil
5657
}
5758

5859
func (cli *fakeClient) TaskInspectWithRaw(_ context.Context, taskID string) (swarm.Task, []byte, error) {

cli/command/node/formatter.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import (
99
"github.com/docker/cli/cli/command"
1010
"github.com/docker/cli/cli/command/formatter"
1111
"github.com/docker/cli/cli/command/inspect"
12-
"github.com/docker/docker/api/types"
1312
"github.com/docker/docker/api/types/swarm"
13+
"github.com/docker/docker/api/types/system"
1414
units "github.com/docker/go-units"
1515
)
1616

@@ -100,7 +100,7 @@ func NewFormat(source string, quiet bool) formatter.Format {
100100
}
101101

102102
// FormatWrite writes the context
103-
func FormatWrite(ctx formatter.Context, nodes []swarm.Node, info types.Info) error {
103+
func FormatWrite(ctx formatter.Context, nodes []swarm.Node, info system.Info) error {
104104
render := func(format func(subContext formatter.SubContext) error) error {
105105
for _, node := range nodes {
106106
nodeCtx := &nodeContext{n: node, info: info}
@@ -127,7 +127,7 @@ func FormatWrite(ctx formatter.Context, nodes []swarm.Node, info types.Info) err
127127
type nodeContext struct {
128128
formatter.HeaderContext
129129
n swarm.Node
130-
info types.Info
130+
info system.Info
131131
}
132132

133133
func (c *nodeContext) MarshalJSON() ([]byte, error) {

cli/command/node/formatter_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import (
99

1010
"github.com/docker/cli/cli/command/formatter"
1111
"github.com/docker/cli/internal/test"
12-
"github.com/docker/docker/api/types"
1312
"github.com/docker/docker/api/types/swarm"
13+
"github.com/docker/docker/api/types/system"
1414
"github.com/docker/docker/pkg/stringid"
1515
"gotest.tools/v3/assert"
1616
is "gotest.tools/v3/assert/cmp"
@@ -204,7 +204,7 @@ foobar_boo Unknown
204204
var out bytes.Buffer
205205
tc.context.Output = &out
206206

207-
err := FormatWrite(tc.context, nodes, types.Info{Swarm: swarm.Info{Cluster: &tc.clusterInfo}})
207+
err := FormatWrite(tc.context, nodes, system.Info{Swarm: swarm.Info{Cluster: &tc.clusterInfo}})
208208
if err != nil {
209209
assert.Error(t, err, tc.expected)
210210
} else {
@@ -217,23 +217,23 @@ foobar_boo Unknown
217217
func TestNodeContextWriteJSON(t *testing.T) {
218218
cases := []struct {
219219
expected []map[string]interface{}
220-
info types.Info
220+
info system.Info
221221
}{
222222
{
223223
expected: []map[string]interface{}{
224224
{"Availability": "", "Hostname": "foobar_baz", "ID": "nodeID1", "ManagerStatus": "", "Status": "", "Self": false, "TLSStatus": "Unknown", "EngineVersion": "1.2.3"},
225225
{"Availability": "", "Hostname": "foobar_bar", "ID": "nodeID2", "ManagerStatus": "", "Status": "", "Self": false, "TLSStatus": "Unknown", "EngineVersion": ""},
226226
{"Availability": "", "Hostname": "foobar_boo", "ID": "nodeID3", "ManagerStatus": "", "Status": "", "Self": false, "TLSStatus": "Unknown", "EngineVersion": "18.03.0-ce"},
227227
},
228-
info: types.Info{},
228+
info: system.Info{},
229229
},
230230
{
231231
expected: []map[string]interface{}{
232232
{"Availability": "", "Hostname": "foobar_baz", "ID": "nodeID1", "ManagerStatus": "", "Status": "", "Self": false, "TLSStatus": "Ready", "EngineVersion": "1.2.3"},
233233
{"Availability": "", "Hostname": "foobar_bar", "ID": "nodeID2", "ManagerStatus": "", "Status": "", "Self": false, "TLSStatus": "Needs Rotation", "EngineVersion": ""},
234234
{"Availability": "", "Hostname": "foobar_boo", "ID": "nodeID3", "ManagerStatus": "", "Status": "", "Self": false, "TLSStatus": "Unknown", "EngineVersion": "18.03.0-ce"},
235235
},
236-
info: types.Info{
236+
info: system.Info{
237237
Swarm: swarm.Info{
238238
Cluster: &swarm.ClusterInfo{
239239
TLSInfo: swarm.TLSInfo{TrustRoot: "hi"},
@@ -271,7 +271,7 @@ func TestNodeContextWriteJSONField(t *testing.T) {
271271
{ID: "nodeID2", Description: swarm.NodeDescription{Hostname: "foobar_bar"}},
272272
}
273273
out := bytes.NewBufferString("")
274-
err := FormatWrite(formatter.Context{Format: "{{json .ID}}", Output: out}, nodes, types.Info{})
274+
err := FormatWrite(formatter.Context{Format: "{{json .ID}}", Output: out}, nodes, system.Info{})
275275
if err != nil {
276276
t.Fatal(err)
277277
}

cli/command/node/inspect_test.go

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

88
"github.com/docker/cli/internal/test"
99
. "github.com/docker/cli/internal/test/builders" // Import builders to get the builder function as package functions
10-
"github.com/docker/docker/api/types"
1110
"github.com/docker/docker/api/types/swarm"
11+
"github.com/docker/docker/api/types/system"
1212
"github.com/pkg/errors"
1313
"gotest.tools/v3/assert"
1414
"gotest.tools/v3/golden"
@@ -19,16 +19,16 @@ func TestNodeInspectErrors(t *testing.T) {
1919
args []string
2020
flags map[string]string
2121
nodeInspectFunc func() (swarm.Node, []byte, error)
22-
infoFunc func() (types.Info, error)
22+
infoFunc func() (system.Info, error)
2323
expectedError string
2424
}{
2525
{
2626
expectedError: "requires at least 1 argument",
2727
},
2828
{
2929
args: []string{"self"},
30-
infoFunc: func() (types.Info, error) {
31-
return types.Info{}, errors.Errorf("error asking for node info")
30+
infoFunc: func() (system.Info, error) {
31+
return system.Info{}, errors.Errorf("error asking for node info")
3232
},
3333
expectedError: "error asking for node info",
3434
},
@@ -37,8 +37,8 @@ func TestNodeInspectErrors(t *testing.T) {
3737
nodeInspectFunc: func() (swarm.Node, []byte, error) {
3838
return swarm.Node{}, []byte{}, errors.Errorf("error inspecting the node")
3939
},
40-
infoFunc: func() (types.Info, error) {
41-
return types.Info{}, errors.Errorf("error asking for node info")
40+
infoFunc: func() (system.Info, error) {
41+
return system.Info{}, errors.Errorf("error asking for node info")
4242
},
4343
expectedError: "error inspecting the node",
4444
},
@@ -47,8 +47,8 @@ func TestNodeInspectErrors(t *testing.T) {
4747
nodeInspectFunc: func() (swarm.Node, []byte, error) {
4848
return swarm.Node{}, []byte{}, errors.Errorf("error inspecting the node")
4949
},
50-
infoFunc: func() (types.Info, error) {
51-
return types.Info{Swarm: swarm.Info{NodeID: "abc"}}, nil
50+
infoFunc: func() (system.Info, error) {
51+
return system.Info{Swarm: swarm.Info{NodeID: "abc"}}, nil
5252
},
5353
expectedError: "error inspecting the node",
5454
},
@@ -57,8 +57,8 @@ func TestNodeInspectErrors(t *testing.T) {
5757
flags: map[string]string{
5858
"pretty": "true",
5959
},
60-
infoFunc: func() (types.Info, error) {
61-
return types.Info{}, errors.Errorf("error asking for node info")
60+
infoFunc: func() (system.Info, error) {
61+
return system.Info{}, errors.Errorf("error asking for node info")
6262
},
6363
expectedError: "error asking for node info",
6464
},

cli/command/node/list.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
flagsHelper "github.com/docker/cli/cli/flags"
1212
"github.com/docker/cli/opts"
1313
"github.com/docker/docker/api/types"
14+
"github.com/docker/docker/api/types/system"
1415
"github.com/fvbommel/sortorder"
1516
"github.com/spf13/cobra"
1617
)
@@ -53,7 +54,7 @@ func runList(dockerCli command.Cli, options listOptions) error {
5354
return err
5455
}
5556

56-
info := types.Info{}
57+
info := system.Info{}
5758
if len(nodes) > 0 && !options.quiet {
5859
// only non-empty nodes and not quiet, should we call /info api
5960
info, err = client.Info(ctx)

cli/command/node/list_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import (
77
"github.com/docker/cli/cli/config/configfile"
88
"github.com/docker/cli/internal/test"
99
. "github.com/docker/cli/internal/test/builders" // Import builders to get the builder function as package function
10-
"github.com/docker/docker/api/types"
1110
"github.com/docker/docker/api/types/swarm"
11+
"github.com/docker/docker/api/types/system"
1212
"github.com/pkg/errors"
1313
"gotest.tools/v3/assert"
1414
is "gotest.tools/v3/assert/cmp"
@@ -18,7 +18,7 @@ import (
1818
func TestNodeListErrorOnAPIFailure(t *testing.T) {
1919
testCases := []struct {
2020
nodeListFunc func() ([]swarm.Node, error)
21-
infoFunc func() (types.Info, error)
21+
infoFunc func() (system.Info, error)
2222
expectedError string
2323
}{
2424
{
@@ -35,8 +35,8 @@ func TestNodeListErrorOnAPIFailure(t *testing.T) {
3535
},
3636
}, nil
3737
},
38-
infoFunc: func() (types.Info, error) {
39-
return types.Info{}, errors.Errorf("error asking for node info")
38+
infoFunc: func() (system.Info, error) {
39+
return system.Info{}, errors.Errorf("error asking for node info")
4040
},
4141
expectedError: "error asking for node info",
4242
},
@@ -61,8 +61,8 @@ func TestNodeList(t *testing.T) {
6161
*Node(NodeID("nodeID3"), Hostname("node-1-foo")),
6262
}, nil
6363
},
64-
infoFunc: func() (types.Info, error) {
65-
return types.Info{
64+
infoFunc: func() (system.Info, error) {
65+
return system.Info{
6666
Swarm: swarm.Info{
6767
NodeID: "nodeID1",
6868
},
@@ -98,8 +98,8 @@ func TestNodeListDefaultFormatFromConfig(t *testing.T) {
9898
*Node(NodeID("nodeID3"), Hostname("nodeHostname3")),
9999
}, nil
100100
},
101-
infoFunc: func() (types.Info, error) {
102-
return types.Info{
101+
infoFunc: func() (system.Info, error) {
102+
return system.Info{
103103
Swarm: swarm.Info{
104104
NodeID: "nodeID1",
105105
},
@@ -122,8 +122,8 @@ func TestNodeListFormat(t *testing.T) {
122122
*Node(NodeID("nodeID2"), Hostname("nodeHostname2"), Manager()),
123123
}, nil
124124
},
125-
infoFunc: func() (types.Info, error) {
126-
return types.Info{
125+
infoFunc: func() (system.Info, error) {
126+
return system.Info{
127127
Swarm: swarm.Info{
128128
NodeID: "nodeID1",
129129
},

cli/command/node/ps_test.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
. "github.com/docker/cli/internal/test/builders" // Import builders to get the builder function as package function
1212
"github.com/docker/docker/api/types"
1313
"github.com/docker/docker/api/types/swarm"
14+
"github.com/docker/docker/api/types/system"
1415
"github.com/pkg/errors"
1516
"gotest.tools/v3/assert"
1617
"gotest.tools/v3/golden"
@@ -20,15 +21,15 @@ func TestNodePsErrors(t *testing.T) {
2021
testCases := []struct {
2122
args []string
2223
flags map[string]string
23-
infoFunc func() (types.Info, error)
24+
infoFunc func() (system.Info, error)
2425
nodeInspectFunc func() (swarm.Node, []byte, error)
2526
taskListFunc func(options types.TaskListOptions) ([]swarm.Task, error)
2627
taskInspectFunc func(taskID string) (swarm.Task, []byte, error)
2728
expectedError string
2829
}{
2930
{
30-
infoFunc: func() (types.Info, error) {
31-
return types.Info{}, errors.Errorf("error asking for node info")
31+
infoFunc: func() (system.Info, error) {
32+
return system.Info{}, errors.Errorf("error asking for node info")
3233
},
3334
expectedError: "error asking for node info",
3435
},
@@ -69,7 +70,7 @@ func TestNodePs(t *testing.T) {
6970
name string
7071
args []string
7172
flags map[string]string
72-
infoFunc func() (types.Info, error)
73+
infoFunc func() (system.Info, error)
7374
nodeInspectFunc func() (swarm.Node, []byte, error)
7475
taskListFunc func(options types.TaskListOptions) ([]swarm.Task, error)
7576
taskInspectFunc func(taskID string) (swarm.Task, []byte, error)

0 commit comments

Comments
 (0)