diff --git a/cli/command/container/client_test.go b/cli/command/container/client_test.go index a4c1478b43..43f83b0f96 100644 --- a/cli/command/container/client_test.go +++ b/cli/command/container/client_test.go @@ -7,6 +7,7 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/network" + "github.com/docker/docker/api/types/system" "github.com/docker/docker/client" specs "github.com/opencontainers/image-spec/specs-go/v1" ) @@ -23,7 +24,7 @@ type fakeClient struct { containerName string) (container.CreateResponse, error) containerStartFunc func(container string, options types.ContainerStartOptions) error imageCreateFunc func(parentReference string, options types.ImageCreateOptions) (io.ReadCloser, error) - infoFunc func() (types.Info, error) + infoFunc func() (system.Info, error) containerStatPathFunc func(container, path string) (types.ContainerPathStat, error) containerCopyFromFunc func(container, srcPath string) (io.ReadCloser, types.ContainerPathStat, error) logFunc func(string, types.ContainerLogsOptions) (io.ReadCloser, error) @@ -96,11 +97,11 @@ func (f *fakeClient) ImageCreate(_ context.Context, parentReference string, opti return nil, nil } -func (f *fakeClient) Info(_ context.Context) (types.Info, error) { +func (f *fakeClient) Info(_ context.Context) (system.Info, error) { if f.infoFunc != nil { return f.infoFunc() } - return types.Info{}, nil + return system.Info{}, nil } func (f *fakeClient) ContainerStatPath(_ context.Context, container, path string) (types.ContainerPathStat, error) { diff --git a/cli/command/container/create_test.go b/cli/command/container/create_test.go index 7de0dc6ddb..495e101166 100644 --- a/cli/command/container/create_test.go +++ b/cli/command/container/create_test.go @@ -18,6 +18,7 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/network" + "github.com/docker/docker/api/types/system" "github.com/google/go-cmp/cmp" specs "github.com/opencontainers/image-spec/specs-go/v1" "github.com/spf13/pflag" @@ -137,8 +138,8 @@ func TestCreateContainerImagePullPolicy(t *testing.T) { defer func() { pullCounter++ }() return io.NopCloser(strings.NewReader("")), nil }, - infoFunc: func() (types.Info, error) { - return types.Info{IndexServerAddress: "https://indexserver.example.com"}, nil + infoFunc: func() (system.Info, error) { + return system.Info{IndexServerAddress: "https://indexserver.example.com"}, nil }, } fakeCLI := test.NewFakeCli(client) diff --git a/cli/command/image/client_test.go b/cli/command/image/client_test.go index 99244c7864..4e1fd3abe9 100644 --- a/cli/command/image/client_test.go +++ b/cli/command/image/client_test.go @@ -9,6 +9,7 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/image" + "github.com/docker/docker/api/types/system" "github.com/docker/docker/client" ) @@ -18,7 +19,7 @@ type fakeClient struct { imageSaveFunc func(images []string) (io.ReadCloser, error) imageRemoveFunc func(image string, options types.ImageRemoveOptions) ([]types.ImageDeleteResponseItem, error) imagePushFunc func(ref string, options types.ImagePushOptions) (io.ReadCloser, error) - infoFunc func() (types.Info, error) + infoFunc func() (system.Info, error) imagePullFunc func(ref string, options types.ImagePullOptions) (io.ReadCloser, error) imagesPruneFunc func(pruneFilter filters.Args) (types.ImagesPruneReport, error) 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 return io.NopCloser(strings.NewReader("")), nil } -func (cli *fakeClient) Info(_ context.Context) (types.Info, error) { +func (cli *fakeClient) Info(_ context.Context) (system.Info, error) { if cli.infoFunc != nil { return cli.infoFunc() } - return types.Info{}, nil + return system.Info{}, nil } func (cli *fakeClient) ImagePull(_ context.Context, ref string, options types.ImagePullOptions) (io.ReadCloser, error) { diff --git a/cli/command/node/client_test.go b/cli/command/node/client_test.go index a9cf5ed972..505d07259b 100644 --- a/cli/command/node/client_test.go +++ b/cli/command/node/client_test.go @@ -5,12 +5,13 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/swarm" + "github.com/docker/docker/api/types/system" "github.com/docker/docker/client" ) type fakeClient struct { client.Client - infoFunc func() (types.Info, error) + infoFunc func() (system.Info, error) nodeInspectFunc func() (swarm.Node, []byte, error) nodeListFunc func() ([]swarm.Node, error) nodeRemoveFunc func() error @@ -48,11 +49,11 @@ func (cli *fakeClient) NodeUpdate(_ context.Context, nodeID string, version swar return nil } -func (cli *fakeClient) Info(context.Context) (types.Info, error) { +func (cli *fakeClient) Info(context.Context) (system.Info, error) { if cli.infoFunc != nil { return cli.infoFunc() } - return types.Info{}, nil + return system.Info{}, nil } func (cli *fakeClient) TaskInspectWithRaw(_ context.Context, taskID string) (swarm.Task, []byte, error) { diff --git a/cli/command/node/formatter.go b/cli/command/node/formatter.go index 9cd9d015e0..cc82e6d037 100644 --- a/cli/command/node/formatter.go +++ b/cli/command/node/formatter.go @@ -9,8 +9,8 @@ import ( "github.com/docker/cli/cli/command" "github.com/docker/cli/cli/command/formatter" "github.com/docker/cli/cli/command/inspect" - "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/swarm" + "github.com/docker/docker/api/types/system" units "github.com/docker/go-units" ) @@ -100,7 +100,7 @@ func NewFormat(source string, quiet bool) formatter.Format { } // FormatWrite writes the context -func FormatWrite(ctx formatter.Context, nodes []swarm.Node, info types.Info) error { +func FormatWrite(ctx formatter.Context, nodes []swarm.Node, info system.Info) error { render := func(format func(subContext formatter.SubContext) error) error { for _, node := range nodes { nodeCtx := &nodeContext{n: node, info: info} @@ -127,7 +127,7 @@ func FormatWrite(ctx formatter.Context, nodes []swarm.Node, info types.Info) err type nodeContext struct { formatter.HeaderContext n swarm.Node - info types.Info + info system.Info } func (c *nodeContext) MarshalJSON() ([]byte, error) { diff --git a/cli/command/node/formatter_test.go b/cli/command/node/formatter_test.go index afa44981ae..1d35623e47 100644 --- a/cli/command/node/formatter_test.go +++ b/cli/command/node/formatter_test.go @@ -9,8 +9,8 @@ import ( "github.com/docker/cli/cli/command/formatter" "github.com/docker/cli/internal/test" - "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/swarm" + "github.com/docker/docker/api/types/system" "github.com/docker/docker/pkg/stringid" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" @@ -204,7 +204,7 @@ foobar_boo Unknown var out bytes.Buffer tc.context.Output = &out - err := FormatWrite(tc.context, nodes, types.Info{Swarm: swarm.Info{Cluster: &tc.clusterInfo}}) + err := FormatWrite(tc.context, nodes, system.Info{Swarm: swarm.Info{Cluster: &tc.clusterInfo}}) if err != nil { assert.Error(t, err, tc.expected) } else { @@ -217,7 +217,7 @@ foobar_boo Unknown func TestNodeContextWriteJSON(t *testing.T) { cases := []struct { expected []map[string]interface{} - info types.Info + info system.Info }{ { expected: []map[string]interface{}{ @@ -225,7 +225,7 @@ func TestNodeContextWriteJSON(t *testing.T) { {"Availability": "", "Hostname": "foobar_bar", "ID": "nodeID2", "ManagerStatus": "", "Status": "", "Self": false, "TLSStatus": "Unknown", "EngineVersion": ""}, {"Availability": "", "Hostname": "foobar_boo", "ID": "nodeID3", "ManagerStatus": "", "Status": "", "Self": false, "TLSStatus": "Unknown", "EngineVersion": "18.03.0-ce"}, }, - info: types.Info{}, + info: system.Info{}, }, { expected: []map[string]interface{}{ @@ -233,7 +233,7 @@ func TestNodeContextWriteJSON(t *testing.T) { {"Availability": "", "Hostname": "foobar_bar", "ID": "nodeID2", "ManagerStatus": "", "Status": "", "Self": false, "TLSStatus": "Needs Rotation", "EngineVersion": ""}, {"Availability": "", "Hostname": "foobar_boo", "ID": "nodeID3", "ManagerStatus": "", "Status": "", "Self": false, "TLSStatus": "Unknown", "EngineVersion": "18.03.0-ce"}, }, - info: types.Info{ + info: system.Info{ Swarm: swarm.Info{ Cluster: &swarm.ClusterInfo{ TLSInfo: swarm.TLSInfo{TrustRoot: "hi"}, @@ -271,7 +271,7 @@ func TestNodeContextWriteJSONField(t *testing.T) { {ID: "nodeID2", Description: swarm.NodeDescription{Hostname: "foobar_bar"}}, } out := bytes.NewBufferString("") - err := FormatWrite(formatter.Context{Format: "{{json .ID}}", Output: out}, nodes, types.Info{}) + err := FormatWrite(formatter.Context{Format: "{{json .ID}}", Output: out}, nodes, system.Info{}) if err != nil { t.Fatal(err) } diff --git a/cli/command/node/inspect_test.go b/cli/command/node/inspect_test.go index 2c2e33bedf..205f840f96 100644 --- a/cli/command/node/inspect_test.go +++ b/cli/command/node/inspect_test.go @@ -7,8 +7,8 @@ import ( "github.com/docker/cli/internal/test" . "github.com/docker/cli/internal/test/builders" // Import builders to get the builder function as package functions - "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/swarm" + "github.com/docker/docker/api/types/system" "github.com/pkg/errors" "gotest.tools/v3/assert" "gotest.tools/v3/golden" @@ -19,7 +19,7 @@ func TestNodeInspectErrors(t *testing.T) { args []string flags map[string]string nodeInspectFunc func() (swarm.Node, []byte, error) - infoFunc func() (types.Info, error) + infoFunc func() (system.Info, error) expectedError string }{ { @@ -27,8 +27,8 @@ func TestNodeInspectErrors(t *testing.T) { }, { args: []string{"self"}, - infoFunc: func() (types.Info, error) { - return types.Info{}, errors.Errorf("error asking for node info") + infoFunc: func() (system.Info, error) { + return system.Info{}, errors.Errorf("error asking for node info") }, expectedError: "error asking for node info", }, @@ -37,8 +37,8 @@ func TestNodeInspectErrors(t *testing.T) { nodeInspectFunc: func() (swarm.Node, []byte, error) { return swarm.Node{}, []byte{}, errors.Errorf("error inspecting the node") }, - infoFunc: func() (types.Info, error) { - return types.Info{}, errors.Errorf("error asking for node info") + infoFunc: func() (system.Info, error) { + return system.Info{}, errors.Errorf("error asking for node info") }, expectedError: "error inspecting the node", }, @@ -47,8 +47,8 @@ func TestNodeInspectErrors(t *testing.T) { nodeInspectFunc: func() (swarm.Node, []byte, error) { return swarm.Node{}, []byte{}, errors.Errorf("error inspecting the node") }, - infoFunc: func() (types.Info, error) { - return types.Info{Swarm: swarm.Info{NodeID: "abc"}}, nil + infoFunc: func() (system.Info, error) { + return system.Info{Swarm: swarm.Info{NodeID: "abc"}}, nil }, expectedError: "error inspecting the node", }, @@ -57,8 +57,8 @@ func TestNodeInspectErrors(t *testing.T) { flags: map[string]string{ "pretty": "true", }, - infoFunc: func() (types.Info, error) { - return types.Info{}, errors.Errorf("error asking for node info") + infoFunc: func() (system.Info, error) { + return system.Info{}, errors.Errorf("error asking for node info") }, expectedError: "error asking for node info", }, diff --git a/cli/command/node/list.go b/cli/command/node/list.go index 99d0a428fe..e942789a1b 100644 --- a/cli/command/node/list.go +++ b/cli/command/node/list.go @@ -11,6 +11,7 @@ import ( flagsHelper "github.com/docker/cli/cli/flags" "github.com/docker/cli/opts" "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/system" "github.com/fvbommel/sortorder" "github.com/spf13/cobra" ) @@ -53,7 +54,7 @@ func runList(dockerCli command.Cli, options listOptions) error { return err } - info := types.Info{} + info := system.Info{} if len(nodes) > 0 && !options.quiet { // only non-empty nodes and not quiet, should we call /info api info, err = client.Info(ctx) diff --git a/cli/command/node/list_test.go b/cli/command/node/list_test.go index 6c176795fc..2cf4199900 100644 --- a/cli/command/node/list_test.go +++ b/cli/command/node/list_test.go @@ -7,8 +7,8 @@ import ( "github.com/docker/cli/cli/config/configfile" "github.com/docker/cli/internal/test" . "github.com/docker/cli/internal/test/builders" // Import builders to get the builder function as package function - "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/swarm" + "github.com/docker/docker/api/types/system" "github.com/pkg/errors" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" @@ -18,7 +18,7 @@ import ( func TestNodeListErrorOnAPIFailure(t *testing.T) { testCases := []struct { nodeListFunc func() ([]swarm.Node, error) - infoFunc func() (types.Info, error) + infoFunc func() (system.Info, error) expectedError string }{ { @@ -35,8 +35,8 @@ func TestNodeListErrorOnAPIFailure(t *testing.T) { }, }, nil }, - infoFunc: func() (types.Info, error) { - return types.Info{}, errors.Errorf("error asking for node info") + infoFunc: func() (system.Info, error) { + return system.Info{}, errors.Errorf("error asking for node info") }, expectedError: "error asking for node info", }, @@ -61,8 +61,8 @@ func TestNodeList(t *testing.T) { *Node(NodeID("nodeID3"), Hostname("node-1-foo")), }, nil }, - infoFunc: func() (types.Info, error) { - return types.Info{ + infoFunc: func() (system.Info, error) { + return system.Info{ Swarm: swarm.Info{ NodeID: "nodeID1", }, @@ -98,8 +98,8 @@ func TestNodeListDefaultFormatFromConfig(t *testing.T) { *Node(NodeID("nodeID3"), Hostname("nodeHostname3")), }, nil }, - infoFunc: func() (types.Info, error) { - return types.Info{ + infoFunc: func() (system.Info, error) { + return system.Info{ Swarm: swarm.Info{ NodeID: "nodeID1", }, @@ -122,8 +122,8 @@ func TestNodeListFormat(t *testing.T) { *Node(NodeID("nodeID2"), Hostname("nodeHostname2"), Manager()), }, nil }, - infoFunc: func() (types.Info, error) { - return types.Info{ + infoFunc: func() (system.Info, error) { + return system.Info{ Swarm: swarm.Info{ NodeID: "nodeID1", }, diff --git a/cli/command/node/ps_test.go b/cli/command/node/ps_test.go index 870e8eb187..25d4bc06e8 100644 --- a/cli/command/node/ps_test.go +++ b/cli/command/node/ps_test.go @@ -11,6 +11,7 @@ import ( . "github.com/docker/cli/internal/test/builders" // Import builders to get the builder function as package function "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/swarm" + "github.com/docker/docker/api/types/system" "github.com/pkg/errors" "gotest.tools/v3/assert" "gotest.tools/v3/golden" @@ -20,15 +21,15 @@ func TestNodePsErrors(t *testing.T) { testCases := []struct { args []string flags map[string]string - infoFunc func() (types.Info, error) + infoFunc func() (system.Info, error) nodeInspectFunc func() (swarm.Node, []byte, error) taskListFunc func(options types.TaskListOptions) ([]swarm.Task, error) taskInspectFunc func(taskID string) (swarm.Task, []byte, error) expectedError string }{ { - infoFunc: func() (types.Info, error) { - return types.Info{}, errors.Errorf("error asking for node info") + infoFunc: func() (system.Info, error) { + return system.Info{}, errors.Errorf("error asking for node info") }, expectedError: "error asking for node info", }, @@ -69,7 +70,7 @@ func TestNodePs(t *testing.T) { name string args []string flags map[string]string - infoFunc func() (types.Info, error) + infoFunc func() (system.Info, error) nodeInspectFunc func() (swarm.Node, []byte, error) taskListFunc func(options types.TaskListOptions) ([]swarm.Task, error) taskInspectFunc func(taskID string) (swarm.Task, []byte, error) diff --git a/cli/command/plugin/client_test.go b/cli/command/plugin/client_test.go index 57adccf4f9..c2bd136d0c 100644 --- a/cli/command/plugin/client_test.go +++ b/cli/command/plugin/client_test.go @@ -6,6 +6,7 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/filters" + "github.com/docker/docker/api/types/system" "github.com/docker/docker/client" ) @@ -71,6 +72,6 @@ func (c *fakeClient) PluginInspectWithRaw(_ context.Context, name string) (*type return nil, nil, nil } -func (c *fakeClient) Info(context.Context) (types.Info, error) { - return types.Info{}, nil +func (c *fakeClient) Info(context.Context) (system.Info, error) { + return system.Info{}, nil } diff --git a/cli/command/registry/login_test.go b/cli/command/registry/login_test.go index 8a16925705..263e774fae 100644 --- a/cli/command/registry/login_test.go +++ b/cli/command/registry/login_test.go @@ -8,8 +8,8 @@ import ( configtypes "github.com/docker/cli/cli/config/types" "github.com/docker/cli/internal/test" - "github.com/docker/docker/api/types" registrytypes "github.com/docker/docker/api/types/registry" + "github.com/docker/docker/api/types/system" "github.com/docker/docker/client" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" @@ -34,8 +34,8 @@ type fakeClient struct { client.Client } -func (c fakeClient) Info(context.Context) (types.Info, error) { - return types.Info{}, nil +func (c fakeClient) Info(context.Context) (system.Info, error) { + return system.Info{}, nil } func (c fakeClient) RegistryLogin(_ context.Context, auth registrytypes.AuthConfig) (registrytypes.AuthenticateOKBody, error) { diff --git a/cli/command/registry_test.go b/cli/command/registry_test.go index 6c45614930..4fa8658ebc 100644 --- a/cli/command/registry_test.go +++ b/cli/command/registry_test.go @@ -9,8 +9,8 @@ import ( . "github.com/docker/cli/cli/command" // Prevents a circular import with "github.com/docker/cli/internal/test" configtypes "github.com/docker/cli/cli/config/types" "github.com/docker/cli/internal/test" - "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/registry" + "github.com/docker/docker/api/types/system" "github.com/docker/docker/client" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" @@ -18,7 +18,7 @@ import ( type fakeClient struct { client.Client - infoFunc func() (types.Info, error) + infoFunc func() (system.Info, error) } var testAuthConfigs = []registry.AuthConfig{ @@ -34,11 +34,11 @@ var testAuthConfigs = []registry.AuthConfig{ }, } -func (cli *fakeClient) Info(_ context.Context) (types.Info, error) { +func (cli *fakeClient) Info(_ context.Context) (system.Info, error) { if cli.infoFunc != nil { return cli.infoFunc() } - return types.Info{}, nil + return system.Info{}, nil } func TestGetDefaultAuthConfig(t *testing.T) { diff --git a/cli/command/service/client_test.go b/cli/command/service/client_test.go index d00afe2ca2..eaa1cb489b 100644 --- a/cli/command/service/client_test.go +++ b/cli/command/service/client_test.go @@ -6,6 +6,7 @@ import ( . "github.com/docker/cli/internal/test/builders" // Import builders to get the builder function as package function "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/swarm" + "github.com/docker/docker/api/types/system" "github.com/docker/docker/client" ) @@ -15,7 +16,7 @@ type fakeClient struct { serviceUpdateFunc func(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options types.ServiceUpdateOptions) (types.ServiceUpdateResponse, error) serviceListFunc func(context.Context, types.ServiceListOptions) ([]swarm.Service, error) taskListFunc func(context.Context, types.TaskListOptions) ([]swarm.Task, error) - infoFunc func(ctx context.Context) (types.Info, error) + infoFunc func(ctx context.Context) (system.Info, error) networkInspectFunc func(ctx context.Context, networkID string, options types.NetworkInspectOptions) (types.NetworkResource, error) nodeListFunc func(ctx context.Context, options types.NodeListOptions) ([]swarm.Node, error) } @@ -58,9 +59,9 @@ func (f *fakeClient) ServiceUpdate(ctx context.Context, serviceID string, versio return types.ServiceUpdateResponse{}, nil } -func (f *fakeClient) Info(ctx context.Context) (types.Info, error) { +func (f *fakeClient) Info(ctx context.Context) (system.Info, error) { if f.infoFunc == nil { - return types.Info{}, nil + return system.Info{}, nil } return f.infoFunc(ctx) } diff --git a/cli/command/service/ps_test.go b/cli/command/service/ps_test.go index 40b612bff1..a17f4061be 100644 --- a/cli/command/service/ps_test.go +++ b/cli/command/service/ps_test.go @@ -9,6 +9,7 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/filters" "github.com/docker/docker/api/types/swarm" + "github.com/docker/docker/api/types/system" "github.com/google/go-cmp/cmp" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" @@ -117,8 +118,8 @@ func TestUpdateNodeFilter(t *testing.T) { ) client := &fakeClient{ - infoFunc: func(_ context.Context) (types.Info, error) { - return types.Info{Swarm: swarm.Info{NodeID: selfNodeID}}, nil + infoFunc: func(_ context.Context) (system.Info, error) { + return system.Info{Swarm: swarm.Info{NodeID: selfNodeID}}, nil }, } diff --git a/cli/command/swarm/client_test.go b/cli/command/swarm/client_test.go index e116ed0b16..67eeee175e 100644 --- a/cli/command/swarm/client_test.go +++ b/cli/command/swarm/client_test.go @@ -5,12 +5,13 @@ import ( "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/swarm" + "github.com/docker/docker/api/types/system" "github.com/docker/docker/client" ) type fakeClient struct { client.Client - infoFunc func() (types.Info, error) + infoFunc func() (system.Info, error) swarmInitFunc func() (string, error) swarmInspectFunc func() (swarm.Swarm, error) nodeInspectFunc func() (swarm.Node, []byte, error) @@ -21,11 +22,11 @@ type fakeClient struct { swarmUnlockFunc func(req swarm.UnlockRequest) error } -func (cli *fakeClient) Info(context.Context) (types.Info, error) { +func (cli *fakeClient) Info(context.Context) (system.Info, error) { if cli.infoFunc != nil { return cli.infoFunc() } - return types.Info{}, nil + return system.Info{}, nil } func (cli *fakeClient) NodeInspectWithRaw(context.Context, string) (swarm.Node, []byte, error) { diff --git a/cli/command/swarm/join_test.go b/cli/command/swarm/join_test.go index e8204f3913..5ed5e0a29f 100644 --- a/cli/command/swarm/join_test.go +++ b/cli/command/swarm/join_test.go @@ -6,8 +6,8 @@ import ( "testing" "github.com/docker/cli/internal/test" - "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/swarm" + "github.com/docker/docker/api/types/system" "github.com/pkg/errors" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" @@ -18,7 +18,7 @@ func TestSwarmJoinErrors(t *testing.T) { name string args []string swarmJoinFunc func() error - infoFunc func() (types.Info, error) + infoFunc func() (system.Info, error) expectedError string }{ { @@ -41,8 +41,8 @@ func TestSwarmJoinErrors(t *testing.T) { { name: "join-failed-on-init", args: []string{"remote"}, - infoFunc: func() (types.Info, error) { - return types.Info{}, errors.Errorf("error asking for node info") + infoFunc: func() (system.Info, error) { + return system.Info{}, errors.Errorf("error asking for node info") }, expectedError: "error asking for node info", }, @@ -62,13 +62,13 @@ func TestSwarmJoinErrors(t *testing.T) { func TestSwarmJoin(t *testing.T) { testCases := []struct { name string - infoFunc func() (types.Info, error) + infoFunc func() (system.Info, error) expected string }{ { name: "join-as-manager", - infoFunc: func() (types.Info, error) { - return types.Info{ + infoFunc: func() (system.Info, error) { + return system.Info{ Swarm: swarm.Info{ ControlAvailable: true, }, @@ -78,8 +78,8 @@ func TestSwarmJoin(t *testing.T) { }, { name: "join-as-worker", - infoFunc: func() (types.Info, error) { - return types.Info{ + infoFunc: func() (system.Info, error) { + return system.Info{ Swarm: swarm.Info{ ControlAvailable: false, }, diff --git a/cli/command/swarm/join_token_test.go b/cli/command/swarm/join_token_test.go index 082b54852a..bebe6dfd3c 100644 --- a/cli/command/swarm/join_token_test.go +++ b/cli/command/swarm/join_token_test.go @@ -7,8 +7,8 @@ import ( "github.com/docker/cli/internal/test" . "github.com/docker/cli/internal/test/builders" // Import builders to get the builder function as package function - "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/swarm" + "github.com/docker/docker/api/types/system" "github.com/pkg/errors" "gotest.tools/v3/assert" "gotest.tools/v3/golden" @@ -19,7 +19,7 @@ func TestSwarmJoinTokenErrors(t *testing.T) { name string args []string flags map[string]string - infoFunc func() (types.Info, error) + infoFunc func() (system.Info, error) swarmInspectFunc func() (swarm.Swarm, error) swarmUpdateFunc func(swarm swarm.Spec, flags swarm.UpdateFlags) error nodeInspectFunc func() (swarm.Node, []byte, error) @@ -80,8 +80,8 @@ func TestSwarmJoinTokenErrors(t *testing.T) { { name: "info-failed", args: []string{"worker"}, - infoFunc: func() (types.Info, error) { - return types.Info{}, errors.Errorf("error asking for node info") + infoFunc: func() (system.Info, error) { + return system.Info{}, errors.Errorf("error asking for node info") }, expectedError: "error asking for node info", }, @@ -108,15 +108,15 @@ func TestSwarmJoinToken(t *testing.T) { name string args []string flags map[string]string - infoFunc func() (types.Info, error) + infoFunc func() (system.Info, error) swarmInspectFunc func() (swarm.Swarm, error) nodeInspectFunc func() (swarm.Node, []byte, error) }{ { name: "worker", args: []string{"worker"}, - infoFunc: func() (types.Info, error) { - return types.Info{ + infoFunc: func() (system.Info, error) { + return system.Info{ Swarm: swarm.Info{ NodeID: "nodeID", }, @@ -132,8 +132,8 @@ func TestSwarmJoinToken(t *testing.T) { { name: "manager", args: []string{"manager"}, - infoFunc: func() (types.Info, error) { - return types.Info{ + infoFunc: func() (system.Info, error) { + return system.Info{ Swarm: swarm.Info{ NodeID: "nodeID", }, @@ -152,8 +152,8 @@ func TestSwarmJoinToken(t *testing.T) { flags: map[string]string{ flagRotate: "true", }, - infoFunc: func() (types.Info, error) { - return types.Info{ + infoFunc: func() (system.Info, error) { + return system.Info{ Swarm: swarm.Info{ NodeID: "nodeID", }, diff --git a/cli/command/swarm/unlock_test.go b/cli/command/swarm/unlock_test.go index c7e463a32a..c5d533ea9e 100644 --- a/cli/command/swarm/unlock_test.go +++ b/cli/command/swarm/unlock_test.go @@ -7,8 +7,8 @@ import ( "github.com/docker/cli/cli/streams" "github.com/docker/cli/internal/test" - "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/swarm" + "github.com/docker/docker/api/types/system" "github.com/pkg/errors" "gotest.tools/v3/assert" ) @@ -18,7 +18,7 @@ func TestSwarmUnlockErrors(t *testing.T) { name string args []string swarmUnlockFunc func(req swarm.UnlockRequest) error - infoFunc func() (types.Info, error) + infoFunc func() (system.Info, error) expectedError string }{ { @@ -28,8 +28,8 @@ func TestSwarmUnlockErrors(t *testing.T) { }, { name: "is-not-part-of-a-swarm", - infoFunc: func() (types.Info, error) { - return types.Info{ + infoFunc: func() (system.Info, error) { + return system.Info{ Swarm: swarm.Info{ LocalNodeState: swarm.LocalNodeStateInactive, }, @@ -39,8 +39,8 @@ func TestSwarmUnlockErrors(t *testing.T) { }, { name: "is-not-locked", - infoFunc: func() (types.Info, error) { - return types.Info{ + infoFunc: func() (system.Info, error) { + return system.Info{ Swarm: swarm.Info{ LocalNodeState: swarm.LocalNodeStateActive, }, @@ -50,8 +50,8 @@ func TestSwarmUnlockErrors(t *testing.T) { }, { name: "unlockrequest-failed", - infoFunc: func() (types.Info, error) { - return types.Info{ + infoFunc: func() (system.Info, error) { + return system.Info{ Swarm: swarm.Info{ LocalNodeState: swarm.LocalNodeStateLocked, }, @@ -78,8 +78,8 @@ func TestSwarmUnlockErrors(t *testing.T) { func TestSwarmUnlock(t *testing.T) { input := "unlockKey" dockerCli := test.NewFakeCli(&fakeClient{ - infoFunc: func() (types.Info, error) { - return types.Info{ + infoFunc: func() (system.Info, error) { + return system.Info{ Swarm: swarm.Info{ LocalNodeState: swarm.LocalNodeStateLocked, }, diff --git a/cli/command/system/info.go b/cli/command/system/info.go index cef7dc9856..181090423b 100644 --- a/cli/command/system/info.go +++ b/cli/command/system/info.go @@ -16,8 +16,8 @@ import ( "github.com/docker/cli/cli/debug" flagsHelper "github.com/docker/cli/cli/flags" "github.com/docker/cli/templates" - "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/swarm" + "github.com/docker/docker/api/types/system" "github.com/docker/docker/api/types/versions" "github.com/docker/docker/registry" "github.com/docker/go-units" @@ -40,7 +40,7 @@ type info struct { // preserve backwards compatibility in the JSON rendering // which has ServerInfo immediately within the top-level // object. - *types.Info `json:",omitempty"` + *system.Info `json:",omitempty"` ServerErrors []string `json:",omitempty"` UserName string `json:"-"` @@ -86,7 +86,7 @@ func runInfo(cmd *cobra.Command, dockerCli command.Cli, opts *infoOptions) error clientVersion: newClientVersion(dockerCli.CurrentContext(), nil), Debug: debug.IsEnabled(), }, - Info: &types.Info{}, + Info: &system.Info{}, } if plugins, err := pluginmanager.ListPlugins(dockerCli, cmd.Root()); err == nil { info.ClientInfo.Plugins = plugins @@ -267,7 +267,7 @@ func prettyPrintServerInfo(streams command.Streams, info *info) []error { for _, ci := range []struct { Name string - Commit types.Commit + Commit system.Commit }{ {"containerd", info.ContainerdCommit}, {"runc", info.RuncCommit}, @@ -280,7 +280,7 @@ func prettyPrintServerInfo(streams command.Streams, info *info) []error { fprintln(output) } if len(info.SecurityOptions) != 0 { - if kvs, err := types.DecodeSecurityOptions(info.SecurityOptions); err != nil { + if kvs, err := system.DecodeSecurityOptions(info.SecurityOptions); err != nil { errs = append(errs, err) } else { fprintln(output, " Security Options:") @@ -377,7 +377,7 @@ func prettyPrintServerInfo(streams command.Streams, info *info) []error { } //nolint:gocyclo -func printSwarmInfo(output io.Writer, info types.Info) { +func printSwarmInfo(output io.Writer, info system.Info) { if info.Swarm.LocalNodeState == swarm.LocalNodeStateInactive || info.Swarm.LocalNodeState == swarm.LocalNodeStateLocked { return } @@ -464,11 +464,11 @@ func printServerWarnings(stdErr io.Writer, info *info) { // info.Warnings. This function is used to provide backward compatibility with // daemons that do not provide these warnings. No new warnings should be added // here. -func printSecurityOptionsWarnings(stdErr io.Writer, info types.Info) { +func printSecurityOptionsWarnings(stdErr io.Writer, info system.Info) { if info.OSType == "windows" { return } - kvs, _ := types.DecodeSecurityOptions(info.SecurityOptions) + kvs, _ := system.DecodeSecurityOptions(info.SecurityOptions) for _, so := range kvs { if so.Name != "seccomp" { continue @@ -486,7 +486,7 @@ func printSecurityOptionsWarnings(stdErr io.Writer, info types.Info) { // info.Warnings. This function is used to provide backward compatibility with // daemons that do not provide these warnings. No new warnings should be added // here. -func printServerWarningsLegacy(stdErr io.Writer, info types.Info) { +func printServerWarningsLegacy(stdErr io.Writer, info system.Info) { if info.OSType == "windows" { return } diff --git a/cli/command/system/info_test.go b/cli/command/system/info_test.go index 21eb22967c..19a697d007 100644 --- a/cli/command/system/info_test.go +++ b/cli/command/system/info_test.go @@ -8,9 +8,9 @@ import ( pluginmanager "github.com/docker/cli/cli-plugins/manager" "github.com/docker/cli/internal/test" - "github.com/docker/docker/api/types" registrytypes "github.com/docker/docker/api/types/registry" "github.com/docker/docker/api/types/swarm" + "github.com/docker/docker/api/types/system" "gotest.tools/v3/assert" is "gotest.tools/v3/assert/cmp" "gotest.tools/v3/golden" @@ -24,7 +24,7 @@ func base64Decode(val string) []byte { const sampleID = "EKHL:QDUU:QZ7U:MKGD:VDXK:S27Q:GIPU:24B7:R7VT:DGN6:QCSF:2UBX" -var sampleInfoNoSwarm = types.Info{ +var sampleInfoNoSwarm = system.Info{ ID: sampleID, Containers: 0, ContainersRunning: 0, @@ -39,7 +39,7 @@ var sampleInfoNoSwarm = types.Info{ {"Native Overlay Diff", "true"}, }, SystemStatus: nil, - Plugins: types.PluginsInfo{ + Plugins: system.PluginsInfo{ Volume: []string{"local"}, Network: []string{"bridge", "host", "macvlan", "null", "overlay"}, Authorization: nil, @@ -98,7 +98,7 @@ var sampleInfoNoSwarm = types.Info{ Labels: []string{"provider=digitalocean"}, ExperimentalBuild: false, ServerVersion: "17.06.1-ce", - Runtimes: map[string]types.Runtime{ + Runtimes: map[string]system.Runtime{ "runc": { Path: "docker-runc", Args: nil, @@ -109,20 +109,20 @@ var sampleInfoNoSwarm = types.Info{ LiveRestoreEnabled: false, Isolation: "", InitBinary: "docker-init", - ContainerdCommit: types.Commit{ + ContainerdCommit: system.Commit{ ID: "6e23458c129b551d5c9871e5174f6b1b7f6d1170", Expected: "6e23458c129b551d5c9871e5174f6b1b7f6d1170", }, - RuncCommit: types.Commit{ + RuncCommit: system.Commit{ ID: "810190ceaa507aa2727d7ae6f4790c76ec150bd2", Expected: "810190ceaa507aa2727d7ae6f4790c76ec150bd2", }, - InitCommit: types.Commit{ + InitCommit: system.Commit{ ID: "949e6fa", Expected: "949e6fa", }, SecurityOptions: []string{"name=apparmor", "name=seccomp,profile=default"}, - DefaultAddressPools: []types.NetworkAddressPool{ + DefaultAddressPools: []system.NetworkAddressPool{ { Base: "10.123.0.0/16", Size: 24, diff --git a/cli/command/trust/inspect_pretty_test.go b/cli/command/trust/inspect_pretty_test.go index 2ccfd927d8..196bbd7e62 100644 --- a/cli/command/trust/inspect_pretty_test.go +++ b/cli/command/trust/inspect_pretty_test.go @@ -11,6 +11,7 @@ import ( "github.com/docker/cli/internal/test" notaryfake "github.com/docker/cli/internal/test/notary" "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/system" apiclient "github.com/docker/docker/client" "github.com/theupdateframework/notary" "github.com/theupdateframework/notary/client" @@ -27,8 +28,8 @@ type fakeClient struct { apiclient.Client } -func (c *fakeClient) Info(context.Context) (types.Info, error) { - return types.Info{}, nil +func (c *fakeClient) Info(context.Context) (system.Info, error) { + return system.Info{}, nil } func (c *fakeClient) ImageInspectWithRaw(context.Context, string) (types.ImageInspect, []byte, error) {