1
0
mirror of https://github.com/docker/cli.git synced 2026-01-06 05:41:44 +03:00

Merge pull request #6255 from thaJeztah/bump_modules

vendor: github.com/moby/moby/api, moby/moby/client 7145e7666b8f (master)
This commit is contained in:
Austin Vazquez
2025-08-26 13:37:06 -07:00
committed by GitHub
183 changed files with 809 additions and 851 deletions

View File

@@ -7,8 +7,6 @@ import (
"github.com/docker/cli/cli/command/formatter"
"github.com/moby/moby/api/types/container"
"github.com/moby/moby/api/types/image"
"github.com/moby/moby/api/types/network"
"github.com/moby/moby/api/types/volume"
"github.com/moby/moby/client"
"github.com/spf13/cobra"
)
@@ -79,7 +77,7 @@ func ContainerNames(dockerCLI APIClientProvider, all bool, filters ...func(conta
// VolumeNames offers completion for volumes
func VolumeNames(dockerCLI APIClientProvider) cobra.CompletionFunc {
return func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
list, err := dockerCLI.Client().VolumeList(cmd.Context(), volume.ListOptions{})
list, err := dockerCLI.Client().VolumeList(cmd.Context(), client.VolumeListOptions{})
if err != nil {
return nil, cobra.ShellCompDirectiveError
}
@@ -94,7 +92,7 @@ func VolumeNames(dockerCLI APIClientProvider) cobra.CompletionFunc {
// NetworkNames offers completion for networks
func NetworkNames(dockerCLI APIClientProvider) cobra.CompletionFunc {
return func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
list, err := dockerCLI.Client().NetworkList(cmd.Context(), network.ListOptions{})
list, err := dockerCLI.Client().NetworkList(cmd.Context(), client.NetworkListOptions{})
if err != nil {
return nil, cobra.ShellCompDirectiveError
}

View File

@@ -32,7 +32,7 @@ type fakeClient struct {
client.Client
containerListFunc func(options container.ListOptions) ([]container.Summary, error)
imageListFunc func(options image.ListOptions) ([]image.Summary, error)
networkListFunc func(ctx context.Context, options network.ListOptions) ([]network.Summary, error)
networkListFunc func(ctx context.Context, options client.NetworkListOptions) ([]network.Summary, error)
volumeListFunc func(filter filters.Args) (volume.ListResponse, error)
}
@@ -50,14 +50,14 @@ func (c *fakeClient) ImageList(_ context.Context, options image.ListOptions) ([]
return []image.Summary{}, nil
}
func (c *fakeClient) NetworkList(ctx context.Context, options network.ListOptions) ([]network.Summary, error) {
func (c *fakeClient) NetworkList(ctx context.Context, options client.NetworkListOptions) ([]network.Summary, error) {
if c.networkListFunc != nil {
return c.networkListFunc(ctx, options)
}
return []network.Inspect{}, nil
}
func (c *fakeClient) VolumeList(_ context.Context, options volume.ListOptions) (volume.ListResponse, error) {
func (c *fakeClient) VolumeList(_ context.Context, options client.VolumeListOptions) (volume.ListResponse, error) {
if c.volumeListFunc != nil {
return c.volumeListFunc(options.Filters)
}
@@ -273,7 +273,7 @@ func TestCompleteNetworkNames(t *testing.T) {
for _, tc := range tests {
t.Run(tc.doc, func(t *testing.T) {
comp := NetworkNames(fakeCLI{&fakeClient{
networkListFunc: func(ctx context.Context, options network.ListOptions) ([]network.Summary, error) {
networkListFunc: func(ctx context.Context, options client.NetworkListOptions) ([]network.Summary, error) {
if tc.expDirective == cobra.ShellCompDirectiveError {
return nil, errors.New("some error occurred")
}

View File

@@ -11,7 +11,7 @@ type fakeClient struct {
client.Client
configCreateFunc func(context.Context, swarm.ConfigSpec) (swarm.ConfigCreateResponse, error)
configInspectFunc func(context.Context, string) (swarm.Config, []byte, error)
configListFunc func(context.Context, swarm.ConfigListOptions) ([]swarm.Config, error)
configListFunc func(context.Context, client.ConfigListOptions) ([]swarm.Config, error)
configRemoveFunc func(string) error
}
@@ -29,7 +29,7 @@ func (c *fakeClient) ConfigInspectWithRaw(ctx context.Context, id string) (swarm
return swarm.Config{}, nil, nil
}
func (c *fakeClient) ConfigList(ctx context.Context, options swarm.ConfigListOptions) ([]swarm.Config, error) {
func (c *fakeClient) ConfigList(ctx context.Context, options client.ConfigListOptions) ([]swarm.Config, error) {
if c.configListFunc != nil {
return c.configListFunc(ctx, options)
}

View File

@@ -5,7 +5,7 @@ import (
"github.com/docker/cli/cli/command"
"github.com/docker/cli/cli/command/completion"
"github.com/docker/cli/internal/commands"
"github.com/moby/moby/api/types/swarm"
"github.com/moby/moby/client"
"github.com/spf13/cobra"
)
@@ -37,7 +37,7 @@ func newConfigCommand(dockerCLI command.Cli) *cobra.Command {
// completeNames offers completion for swarm configs
func completeNames(dockerCLI completion.APIClientProvider) cobra.CompletionFunc {
return func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
list, err := dockerCLI.Client().ConfigList(cmd.Context(), swarm.ConfigListOptions{})
list, err := dockerCLI.Client().ConfigList(cmd.Context(), client.ConfigListOptions{})
if err != nil {
return nil, cobra.ShellCompDirectiveError
}

View File

@@ -11,7 +11,7 @@ import (
flagsHelper "github.com/docker/cli/cli/flags"
"github.com/docker/cli/opts"
"github.com/fvbommel/sortorder"
"github.com/moby/moby/api/types/swarm"
"github.com/moby/moby/client"
"github.com/spf13/cobra"
)
@@ -48,7 +48,7 @@ func newConfigListCommand(dockerCLI command.Cli) *cobra.Command {
func runList(ctx context.Context, dockerCLI command.Cli, options listOptions) error {
apiClient := dockerCLI.Client()
configs, err := apiClient.ConfigList(ctx, swarm.ConfigListOptions{Filters: options.filter.Value()})
configs, err := apiClient.ConfigList(ctx, client.ConfigListOptions{Filters: options.filter.Value()})
if err != nil {
return err
}

View File

@@ -11,6 +11,7 @@ import (
"github.com/docker/cli/internal/test"
"github.com/docker/cli/internal/test/builders"
"github.com/moby/moby/api/types/swarm"
"github.com/moby/moby/client"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
"gotest.tools/v3/golden"
@@ -19,7 +20,7 @@ import (
func TestConfigListErrors(t *testing.T) {
testCases := []struct {
args []string
configListFunc func(context.Context, swarm.ConfigListOptions) ([]swarm.Config, error)
configListFunc func(context.Context, client.ConfigListOptions) ([]swarm.Config, error)
expectedError string
}{
{
@@ -27,7 +28,7 @@ func TestConfigListErrors(t *testing.T) {
expectedError: "accepts no argument",
},
{
configListFunc: func(_ context.Context, options swarm.ConfigListOptions) ([]swarm.Config, error) {
configListFunc: func(_ context.Context, options client.ConfigListOptions) ([]swarm.Config, error) {
return []swarm.Config{}, errors.New("error listing configs")
},
expectedError: "error listing configs",
@@ -48,7 +49,7 @@ func TestConfigListErrors(t *testing.T) {
func TestConfigList(t *testing.T) {
cli := test.NewFakeCli(&fakeClient{
configListFunc: func(_ context.Context, options swarm.ConfigListOptions) ([]swarm.Config, error) {
configListFunc: func(_ context.Context, options client.ConfigListOptions) ([]swarm.Config, error) {
return []swarm.Config{
*builders.Config(builders.ConfigID("ID-1-foo"),
builders.ConfigName("1-foo"),
@@ -78,7 +79,7 @@ func TestConfigList(t *testing.T) {
func TestConfigListWithQuietOption(t *testing.T) {
cli := test.NewFakeCli(&fakeClient{
configListFunc: func(_ context.Context, options swarm.ConfigListOptions) ([]swarm.Config, error) {
configListFunc: func(_ context.Context, options client.ConfigListOptions) ([]swarm.Config, error) {
return []swarm.Config{
*builders.Config(builders.ConfigID("ID-foo"), builders.ConfigName("foo")),
*builders.Config(builders.ConfigID("ID-bar"), builders.ConfigName("bar"), builders.ConfigLabels(map[string]string{
@@ -95,7 +96,7 @@ func TestConfigListWithQuietOption(t *testing.T) {
func TestConfigListWithConfigFormat(t *testing.T) {
cli := test.NewFakeCli(&fakeClient{
configListFunc: func(_ context.Context, options swarm.ConfigListOptions) ([]swarm.Config, error) {
configListFunc: func(_ context.Context, options client.ConfigListOptions) ([]swarm.Config, error) {
return []swarm.Config{
*builders.Config(builders.ConfigID("ID-foo"), builders.ConfigName("foo")),
*builders.Config(builders.ConfigID("ID-bar"), builders.ConfigName("bar"), builders.ConfigLabels(map[string]string{
@@ -114,7 +115,7 @@ func TestConfigListWithConfigFormat(t *testing.T) {
func TestConfigListWithFormat(t *testing.T) {
cli := test.NewFakeCli(&fakeClient{
configListFunc: func(_ context.Context, options swarm.ConfigListOptions) ([]swarm.Config, error) {
configListFunc: func(_ context.Context, options client.ConfigListOptions) ([]swarm.Config, error) {
return []swarm.Config{
*builders.Config(builders.ConfigID("ID-foo"), builders.ConfigName("foo")),
*builders.Config(builders.ConfigID("ID-bar"), builders.ConfigName("bar"), builders.ConfigLabels(map[string]string{
@@ -131,7 +132,7 @@ func TestConfigListWithFormat(t *testing.T) {
func TestConfigListWithFilter(t *testing.T) {
cli := test.NewFakeCli(&fakeClient{
configListFunc: func(_ context.Context, options swarm.ConfigListOptions) ([]swarm.Config, error) {
configListFunc: func(_ context.Context, options client.ConfigListOptions) ([]swarm.Config, error) {
assert.Check(t, is.Equal("foo", options.Filters.Get("name")[0]))
assert.Check(t, is.Equal("lbl1=Label-bar", options.Filters.Get("label")[0]))
return []swarm.Config{

View File

@@ -32,7 +32,7 @@ type fakeClient struct {
waitFunc func(string) (<-chan container.WaitResponse, <-chan error)
containerListFunc func(container.ListOptions) ([]container.Summary, error)
containerExportFunc func(string) (io.ReadCloser, error)
containerExecResizeFunc func(id string, options container.ResizeOptions) error
containerExecResizeFunc func(id string, options client.ContainerResizeOptions) error
containerRemoveFunc func(ctx context.Context, containerID string, options container.RemoveOptions) error
containerRestartFunc func(ctx context.Context, containerID string, options container.StopOptions) error
containerStopFunc func(ctx context.Context, containerID string, options container.StopOptions) error
@@ -159,7 +159,7 @@ func (f *fakeClient) ContainerExport(_ context.Context, containerID string) (io.
return nil, nil
}
func (f *fakeClient) ContainerExecResize(_ context.Context, id string, options container.ResizeOptions) error {
func (f *fakeClient) ContainerExecResize(_ context.Context, id string, options client.ContainerResizeOptions) error {
if f.containerExecResizeFunc != nil {
return f.containerExecResizeFunc(id, options)
}

View File

@@ -1016,7 +1016,7 @@ func TestParseLabelfileVariables(t *testing.T) {
func TestParseEntryPoint(t *testing.T) {
config, _, _, err := parseRun([]string{"--entrypoint=anything", "cmd", "img"})
assert.NilError(t, err)
assert.Check(t, is.DeepEqual([]string(config.Entrypoint), []string{"anything"}))
assert.Check(t, is.DeepEqual(config.Entrypoint, []string{"anything"}))
}
func TestValidateDevice(t *testing.T) {

View File

@@ -18,6 +18,7 @@ import (
"github.com/moby/moby/api/types/container"
"github.com/moby/moby/api/types/events"
"github.com/moby/moby/api/types/filters"
"github.com/moby/moby/client"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
)
@@ -164,7 +165,7 @@ func RunStats(ctx context.Context, dockerCLI command.Cli, options *StatsOptions)
// is not valid for filtering containers.
f := options.Filters.Clone()
f.Add("type", string(events.ContainerEventType))
eventChan, errChan := apiClient.Events(ctx, events.ListOptions{
eventChan, errChan := apiClient.Events(ctx, client.EventsListOptions{
Filters: f,
})

View File

@@ -9,7 +9,6 @@ import (
"time"
"github.com/docker/cli/cli/command"
"github.com/moby/moby/api/types/container"
"github.com/moby/moby/client"
"github.com/moby/sys/signal"
"github.com/sirupsen/logrus"
@@ -21,7 +20,7 @@ func resizeTtyTo(ctx context.Context, apiClient client.ContainerAPIClient, id st
return nil
}
options := container.ResizeOptions{
options := client.ContainerResizeOptions{
Height: height,
Width: width,
}

View File

@@ -8,14 +8,14 @@ import (
"github.com/docker/cli/cli/command"
"github.com/docker/cli/internal/test"
"github.com/moby/moby/api/types/container"
"github.com/moby/moby/client"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
)
func TestInitTtySizeErrors(t *testing.T) {
expectedError := "failed to resize tty, using default size\n"
fakeContainerExecResizeFunc := func(id string, options container.ResizeOptions) error {
fakeContainerExecResizeFunc := func(id string, options client.ContainerResizeOptions) error {
return errors.New("Error response from daemon: no such exec")
}
fakeResizeTtyFunc := func(ctx context.Context, cli command.Cli, id string, isExec bool) error {

View File

@@ -69,7 +69,7 @@ func legacyWaitExitOrRemoved(ctx context.Context, apiClient client.APIClient, co
f.Add("container", containerID)
eventCtx, cancel := context.WithCancel(ctx)
eventq, errq := apiClient.Events(eventCtx, events.ListOptions{
eventq, errq := apiClient.Events(eventCtx, client.EventsListOptions{
Filters: f,
})

View File

@@ -344,7 +344,7 @@ func (c *ContainerContext) Networks() string {
// DisplayablePorts returns formatted string representing open ports of container
// e.g. "0.0.0.0:80->9090/tcp, 9988/tcp"
// it's used by command 'docker ps'
func DisplayablePorts(ports []container.Port) string {
func DisplayablePorts(ports []container.PortSummary) string {
type portGroup struct {
first uint16
last uint16
@@ -410,7 +410,7 @@ func formGroup(key string, start, last uint16) string {
return group + "/" + groupType
}
func comparePorts(i, j container.Port) bool {
func comparePorts(i, j container.PortSummary) bool {
if i.PrivatePort != j.PrivatePort {
return i.PrivatePort < j.PrivatePort
}

View File

@@ -137,7 +137,7 @@ func TestContainerPsContext(t *testing.T) {
call: ctx.CreatedAt,
},
{
container: container.Summary{Ports: []container.Port{{PrivatePort: 8080, PublicPort: 8080, Type: "tcp"}}},
container: container.Summary{Ports: []container.PortSummary{{PrivatePort: 8080, PublicPort: 8080, Type: "tcp"}}},
trunc: true,
expValue: "8080/tcp",
call: ctx.Ports,
@@ -586,7 +586,7 @@ func TestContainerBackCompat(t *testing.T) {
ImageManifestDescriptor: nil,
Command: "/bin/sh",
Created: createdAtTime.UTC().Unix(),
Ports: []container.Port{{PrivatePort: 8080, PublicPort: 8080, Type: "tcp"}},
Ports: []container.PortSummary{{PrivatePort: 8080, PublicPort: 8080, Type: "tcp"}},
SizeRw: 123,
SizeRootFs: 12345,
Labels: map[string]string{"label1": "value1", "label2": "value2"},
@@ -633,14 +633,14 @@ func TestContainerBackCompat(t *testing.T) {
}
type ports struct {
ports []container.Port
ports []container.PortSummary
expected string
}
func TestDisplayablePorts(t *testing.T) {
cases := []ports{
{
ports: []container.Port{
ports: []container.PortSummary{
{
PrivatePort: 9988,
Type: "tcp",
@@ -649,7 +649,7 @@ func TestDisplayablePorts(t *testing.T) {
expected: "9988/tcp",
},
{
ports: []container.Port{
ports: []container.PortSummary{
{
PrivatePort: 9988,
Type: "udp",
@@ -658,7 +658,7 @@ func TestDisplayablePorts(t *testing.T) {
expected: "9988/udp",
},
{
ports: []container.Port{
ports: []container.PortSummary{
{
IP: "0.0.0.0",
PrivatePort: 9988,
@@ -668,7 +668,7 @@ func TestDisplayablePorts(t *testing.T) {
expected: "0.0.0.0:0->9988/tcp",
},
{
ports: []container.Port{
ports: []container.PortSummary{
{
IP: "::",
PrivatePort: 9988,
@@ -678,7 +678,7 @@ func TestDisplayablePorts(t *testing.T) {
expected: "[::]:0->9988/tcp",
},
{
ports: []container.Port{
ports: []container.PortSummary{
{
PrivatePort: 9988,
PublicPort: 8899,
@@ -688,7 +688,7 @@ func TestDisplayablePorts(t *testing.T) {
expected: "9988/tcp",
},
{
ports: []container.Port{
ports: []container.PortSummary{
{
IP: "4.3.2.1",
PrivatePort: 9988,
@@ -699,7 +699,7 @@ func TestDisplayablePorts(t *testing.T) {
expected: "4.3.2.1:8899->9988/tcp",
},
{
ports: []container.Port{
ports: []container.PortSummary{
{
IP: "::1",
PrivatePort: 9988,
@@ -710,7 +710,7 @@ func TestDisplayablePorts(t *testing.T) {
expected: "[::1]:8899->9988/tcp",
},
{
ports: []container.Port{
ports: []container.PortSummary{
{
IP: "4.3.2.1",
PrivatePort: 9988,
@@ -721,7 +721,7 @@ func TestDisplayablePorts(t *testing.T) {
expected: "4.3.2.1:9988->9988/tcp",
},
{
ports: []container.Port{
ports: []container.PortSummary{
{
IP: "::1",
PrivatePort: 9988,
@@ -732,7 +732,7 @@ func TestDisplayablePorts(t *testing.T) {
expected: "[::1]:9988->9988/tcp",
},
{
ports: []container.Port{
ports: []container.PortSummary{
{
PrivatePort: 9988,
Type: "udp",
@@ -744,7 +744,7 @@ func TestDisplayablePorts(t *testing.T) {
expected: "9988/udp, 9988/udp",
},
{
ports: []container.Port{
ports: []container.PortSummary{
{
IP: "1.2.3.4",
PublicPort: 9998,
@@ -760,7 +760,7 @@ func TestDisplayablePorts(t *testing.T) {
expected: "1.2.3.4:9998-9999->9998-9999/udp",
},
{
ports: []container.Port{
ports: []container.PortSummary{
{
IP: "::1",
PublicPort: 9998,
@@ -776,7 +776,7 @@ func TestDisplayablePorts(t *testing.T) {
expected: "[::1]:9998-9999->9998-9999/udp",
},
{
ports: []container.Port{
ports: []container.PortSummary{
{
IP: "1.2.3.4",
PublicPort: 8887,
@@ -792,7 +792,7 @@ func TestDisplayablePorts(t *testing.T) {
expected: "1.2.3.4:8887->9998/udp, 1.2.3.4:8888->9999/udp",
},
{
ports: []container.Port{
ports: []container.PortSummary{
{
IP: "::1",
PublicPort: 8887,
@@ -808,7 +808,7 @@ func TestDisplayablePorts(t *testing.T) {
expected: "[::1]:8887->9998/udp, [::1]:8888->9999/udp",
},
{
ports: []container.Port{
ports: []container.PortSummary{
{
PrivatePort: 9998,
Type: "udp",
@@ -820,7 +820,7 @@ func TestDisplayablePorts(t *testing.T) {
expected: "9998-9999/udp",
},
{
ports: []container.Port{
ports: []container.PortSummary{
{
IP: "1.2.3.4",
PrivatePort: 6677,
@@ -835,7 +835,7 @@ func TestDisplayablePorts(t *testing.T) {
expected: "9988/udp, 1.2.3.4:7766->6677/tcp",
},
{
ports: []container.Port{
ports: []container.PortSummary{
{
IP: "1.2.3.4",
PrivatePort: 9988,
@@ -861,7 +861,7 @@ func TestDisplayablePorts(t *testing.T) {
expected: "4.3.2.1:3322->2233/tcp, [::1]:3322->2233/tcp, 1.2.3.4:8899->9988/tcp, 1.2.3.4:8899->9988/udp",
},
{
ports: []container.Port{
ports: []container.PortSummary{
{
PrivatePort: 9988,
PublicPort: 8899,
@@ -881,7 +881,7 @@ func TestDisplayablePorts(t *testing.T) {
expected: "9988/udp, 4.3.2.1:3322->2233/tcp, 1.2.3.4:7766->6677/tcp",
},
{
ports: []container.Port{
ports: []container.PortSummary{
{
PrivatePort: 80,
Type: "tcp",

View File

@@ -20,7 +20,7 @@ func (cli *fakeClient) NodeInspectWithRaw(_ context.Context, nodeID string) (swa
return swarm.Node{}, []byte{}, nil
}
func (cli *fakeClient) ServiceInspectWithRaw(_ context.Context, serviceID string, _ swarm.ServiceInspectOptions) (swarm.Service, []byte, error) {
func (cli *fakeClient) ServiceInspectWithRaw(_ context.Context, serviceID string, _ client.ServiceInspectOptions) (swarm.Service, []byte, error) {
if cli.serviceInspectFunc != nil {
return cli.serviceInspectFunc(serviceID)
}

View File

@@ -43,7 +43,7 @@ func (r *IDResolver) get(ctx context.Context, t any, id string) (string, error)
}
return id, nil
case swarm.Service:
service, _, err := r.client.ServiceInspectWithRaw(ctx, id, swarm.ServiceInspectOptions{})
service, _, err := r.client.ServiceInspectWithRaw(ctx, id, client.ServiceInspectOptions{})
if err != nil {
// TODO(thaJeztah): should error-handling be more specific, or is it ok to ignore any error?
return id, nil //nolint:nilerr // ignore nil-error being returned, as this is a best-effort.

View File

@@ -18,9 +18,9 @@ import (
"github.com/docker/cli/internal/jsonstream"
"github.com/docker/cli/internal/registry"
"github.com/docker/cli/internal/tui"
"github.com/moby/moby/api/pkg/authconfig"
"github.com/moby/moby/api/types/auxprogress"
"github.com/moby/moby/api/types/image"
registrytypes "github.com/moby/moby/api/types/registry"
"github.com/morikuni/aec"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors"
@@ -111,7 +111,7 @@ To push the complete multi-platform image, remove the --platform flag.
// Resolve the Auth config relevant for this server
authConfig := command.ResolveAuthConfig(dockerCli.ConfigFile(), indexInfo)
encodedAuth, err := registrytypes.EncodeAuthConfig(authConfig)
encodedAuth, err := authconfig.Encode(authConfig)
if err != nil {
return err
}

View File

@@ -12,6 +12,7 @@ import (
"github.com/docker/cli/cli/streams"
"github.com/docker/cli/cli/trust"
"github.com/docker/cli/internal/jsonstream"
"github.com/moby/moby/api/pkg/authconfig"
"github.com/moby/moby/api/types/image"
registrytypes "github.com/moby/moby/api/types/registry"
"github.com/opencontainers/go-digest"
@@ -149,7 +150,7 @@ func getTrustedPullTargets(cli command.Cli, imgRefAndAuth trust.ImageRefAndAuth)
// imagePullPrivileged pulls the image and displays it to the output
func imagePullPrivileged(ctx context.Context, cli command.Cli, imgRefAndAuth trust.ImageRefAndAuth, opts pullOptions) error {
encodedAuth, err := registrytypes.EncodeAuthConfig(*imgRefAndAuth.AuthConfig())
encodedAuth, err := authconfig.Encode(*imgRefAndAuth.AuthConfig())
if err != nil {
return err
}

View File

@@ -14,9 +14,9 @@ type fakeClient struct {
networkConnectFunc func(ctx context.Context, networkID, container string, config *network.EndpointSettings) error
networkDisconnectFunc func(ctx context.Context, networkID, container string, force bool) error
networkRemoveFunc func(ctx context.Context, networkID string) error
networkListFunc func(ctx context.Context, options network.ListOptions) ([]network.Summary, error)
networkListFunc func(ctx context.Context, options client.NetworkListOptions) ([]network.Summary, error)
networkPruneFunc func(ctx context.Context, pruneFilters filters.Args) (network.PruneReport, error)
networkInspectFunc func(ctx context.Context, networkID string, options network.InspectOptions) (network.Inspect, []byte, error)
networkInspectFunc func(ctx context.Context, networkID string, options client.NetworkInspectOptions) (network.Inspect, []byte, error)
}
func (c *fakeClient) NetworkCreate(ctx context.Context, name string, options network.CreateOptions) (network.CreateResponse, error) {
@@ -40,7 +40,7 @@ func (c *fakeClient) NetworkDisconnect(ctx context.Context, networkID, container
return nil
}
func (c *fakeClient) NetworkList(ctx context.Context, options network.ListOptions) ([]network.Summary, error) {
func (c *fakeClient) NetworkList(ctx context.Context, options client.NetworkListOptions) ([]network.Summary, error) {
if c.networkListFunc != nil {
return c.networkListFunc(ctx, options)
}
@@ -54,7 +54,7 @@ func (c *fakeClient) NetworkRemove(ctx context.Context, networkID string) error
return nil
}
func (c *fakeClient) NetworkInspectWithRaw(ctx context.Context, networkID string, opts network.InspectOptions) (network.Inspect, []byte, error) {
func (c *fakeClient) NetworkInspectWithRaw(ctx context.Context, networkID string, opts client.NetworkInspectOptions) (network.Inspect, []byte, error) {
if c.networkInspectFunc != nil {
return c.networkInspectFunc(ctx, networkID, opts)
}

View File

@@ -12,7 +12,6 @@ import (
"github.com/docker/cli/cli/command/completion"
"github.com/docker/cli/cli/command/inspect"
flagsHelper "github.com/docker/cli/cli/flags"
"github.com/moby/moby/api/types/network"
"github.com/moby/moby/client"
"github.com/spf13/cobra"
)
@@ -45,6 +44,6 @@ func newInspectCommand(dockerCLI command.Cli) *cobra.Command {
func runInspect(ctx context.Context, apiClient client.NetworkAPIClient, output io.Writer, opts inspectOptions) error {
return inspect.Inspect(output, opts.names, opts.format, func(name string) (any, []byte, error) {
return apiClient.NetworkInspectWithRaw(ctx, name, network.InspectOptions{Verbose: opts.verbose})
return apiClient.NetworkInspectWithRaw(ctx, name, client.NetworkInspectOptions{Verbose: opts.verbose})
})
}

View File

@@ -11,7 +11,7 @@ import (
flagsHelper "github.com/docker/cli/cli/flags"
"github.com/docker/cli/opts"
"github.com/fvbommel/sortorder"
"github.com/moby/moby/api/types/network"
"github.com/moby/moby/client"
"github.com/spf13/cobra"
)
@@ -47,7 +47,7 @@ func newListCommand(dockerCli command.Cli) *cobra.Command {
func runList(ctx context.Context, dockerCLI command.Cli, options listOptions) error {
apiClient := dockerCLI.Client()
networkResources, err := apiClient.NetworkList(ctx, network.ListOptions{Filters: options.filter.Value()})
networkResources, err := apiClient.NetworkList(ctx, client.NetworkListOptions{Filters: options.filter.Value()})
if err != nil {
return err
}

View File

@@ -11,6 +11,7 @@ import (
"github.com/google/go-cmp/cmp"
"github.com/moby/moby/api/types/filters"
"github.com/moby/moby/api/types/network"
"github.com/moby/moby/client"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
"gotest.tools/v3/golden"
@@ -18,11 +19,11 @@ import (
func TestNetworkListErrors(t *testing.T) {
testCases := []struct {
networkListFunc func(ctx context.Context, options network.ListOptions) ([]network.Summary, error)
networkListFunc func(ctx context.Context, options client.NetworkListOptions) ([]network.Summary, error)
expectedError string
}{
{
networkListFunc: func(ctx context.Context, options network.ListOptions) ([]network.Summary, error) {
networkListFunc: func(ctx context.Context, options client.NetworkListOptions) ([]network.Summary, error) {
return []network.Summary{}, errors.New("error creating network")
},
expectedError: "error creating network",
@@ -44,7 +45,7 @@ func TestNetworkListErrors(t *testing.T) {
func TestNetworkList(t *testing.T) {
testCases := []struct {
doc string
networkListFunc func(ctx context.Context, options network.ListOptions) ([]network.Summary, error)
networkListFunc func(ctx context.Context, options client.NetworkListOptions) ([]network.Summary, error)
flags map[string]string
golden string
}{
@@ -54,8 +55,8 @@ func TestNetworkList(t *testing.T) {
"filter": "image.name=ubuntu",
},
golden: "network-list.golden",
networkListFunc: func(ctx context.Context, options network.ListOptions) ([]network.Summary, error) {
expectedOpts := network.ListOptions{
networkListFunc: func(ctx context.Context, options client.NetworkListOptions) ([]network.Summary, error) {
expectedOpts := client.NetworkListOptions{
Filters: filters.NewArgs(filters.Arg("image.name", "ubuntu")),
}
assert.Check(t, is.DeepEqual(expectedOpts, options, cmp.AllowUnexported(filters.Args{})))
@@ -72,7 +73,7 @@ func TestNetworkList(t *testing.T) {
"format": "{{ .Name }}",
},
golden: "network-list-sort.golden",
networkListFunc: func(ctx context.Context, options network.ListOptions) ([]network.Summary, error) {
networkListFunc: func(ctx context.Context, options client.NetworkListOptions) ([]network.Summary, error) {
return []network.Summary{
*builders.NetworkResource(builders.NetworkResourceName("network-2-foo")),
*builders.NetworkResource(builders.NetworkResourceName("network-1-foo")),

View File

@@ -10,7 +10,7 @@ import (
"github.com/docker/cli/cli/command"
"github.com/docker/cli/cli/command/completion"
"github.com/docker/cli/internal/prompt"
"github.com/moby/moby/api/types/network"
"github.com/moby/moby/client"
"github.com/spf13/cobra"
)
@@ -48,7 +48,7 @@ func runRemove(ctx context.Context, dockerCLI command.Cli, networks []string, op
status := 0
for _, name := range networks {
nw, _, err := apiClient.NetworkInspectWithRaw(ctx, name, network.InspectOptions{})
nw, _, err := apiClient.NetworkInspectWithRaw(ctx, name, client.NetworkInspectOptions{})
if err == nil && nw.Ingress {
r, err := prompt.Confirm(ctx, dockerCLI.In(), dockerCLI.Out(), ingressWarning)
if err != nil {

View File

@@ -8,6 +8,7 @@ import (
"github.com/docker/cli/internal/test"
"github.com/moby/moby/api/types/network"
"github.com/moby/moby/client"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
)
@@ -110,7 +111,7 @@ func TestNetworkRemovePromptTermination(t *testing.T) {
networkRemoveFunc: func(ctx context.Context, networkID string) error {
return errors.New("fakeClient networkRemoveFunc should not be called")
},
networkInspectFunc: func(ctx context.Context, networkID string, options network.InspectOptions) (network.Inspect, []byte, error) {
networkInspectFunc: func(ctx context.Context, networkID string, options client.NetworkInspectOptions) (network.Inspect, []byte, error) {
return network.Inspect{
ID: "existing-network",
Name: "existing-network",

View File

@@ -16,8 +16,8 @@ type fakeClient struct {
nodeRemoveFunc func() error
nodeUpdateFunc func(nodeID string, version swarm.Version, node swarm.NodeSpec) error
taskInspectFunc func(taskID string) (swarm.Task, []byte, error)
taskListFunc func(options swarm.TaskListOptions) ([]swarm.Task, error)
serviceInspectFunc func(ctx context.Context, serviceID string, opts swarm.ServiceInspectOptions) (swarm.Service, []byte, error)
taskListFunc func(options client.TaskListOptions) ([]swarm.Task, error)
serviceInspectFunc func(ctx context.Context, serviceID string, opts client.ServiceInspectOptions) (swarm.Service, []byte, error)
}
func (cli *fakeClient) NodeInspectWithRaw(context.Context, string) (swarm.Node, []byte, error) {
@@ -27,14 +27,14 @@ func (cli *fakeClient) NodeInspectWithRaw(context.Context, string) (swarm.Node,
return swarm.Node{}, []byte{}, nil
}
func (cli *fakeClient) NodeList(context.Context, swarm.NodeListOptions) ([]swarm.Node, error) {
func (cli *fakeClient) NodeList(context.Context, client.NodeListOptions) ([]swarm.Node, error) {
if cli.nodeListFunc != nil {
return cli.nodeListFunc()
}
return []swarm.Node{}, nil
}
func (cli *fakeClient) NodeRemove(context.Context, string, swarm.NodeRemoveOptions) error {
func (cli *fakeClient) NodeRemove(context.Context, string, client.NodeRemoveOptions) error {
if cli.nodeRemoveFunc != nil {
return cli.nodeRemoveFunc()
}
@@ -62,14 +62,14 @@ func (cli *fakeClient) TaskInspectWithRaw(_ context.Context, taskID string) (swa
return swarm.Task{}, []byte{}, nil
}
func (cli *fakeClient) TaskList(_ context.Context, options swarm.TaskListOptions) ([]swarm.Task, error) {
func (cli *fakeClient) TaskList(_ context.Context, options client.TaskListOptions) ([]swarm.Task, error) {
if cli.taskListFunc != nil {
return cli.taskListFunc(options)
}
return []swarm.Task{}, nil
}
func (cli *fakeClient) ServiceInspectWithRaw(ctx context.Context, serviceID string, opts swarm.ServiceInspectOptions) (swarm.Service, []byte, error) {
func (cli *fakeClient) ServiceInspectWithRaw(ctx context.Context, serviceID string, opts client.ServiceInspectOptions) (swarm.Service, []byte, error) {
if cli.serviceInspectFunc != nil {
return cli.serviceInspectFunc(ctx, serviceID, opts)
}

View File

@@ -7,7 +7,6 @@ import (
"github.com/docker/cli/cli"
"github.com/docker/cli/cli/command"
"github.com/docker/cli/internal/commands"
"github.com/moby/moby/api/types/swarm"
"github.com/moby/moby/client"
"github.com/spf13/cobra"
)
@@ -55,7 +54,7 @@ func Reference(ctx context.Context, apiClient client.APIClient, ref string) (str
// get a more specific error message.
//
// FIXME(thaJeztah): this should not require calling a Swarm endpoint, and we could just suffice with info / ping (which has swarm status).
_, err = apiClient.NodeList(ctx, swarm.NodeListOptions{})
_, err = apiClient.NodeList(ctx, client.NodeListOptions{})
if err != nil {
return "", err
}

View File

@@ -4,7 +4,7 @@ import (
"os"
"github.com/docker/cli/cli/command/completion"
"github.com/moby/moby/api/types/swarm"
"github.com/moby/moby/client"
"github.com/spf13/cobra"
)
@@ -17,7 +17,7 @@ func completeNodeNames(dockerCLI completion.APIClientProvider) cobra.CompletionF
// https://github.com/docker/cli/blob/f9ced58158d5e0b358052432244b483774a1983d/contrib/completion/bash/docker#L41-L43
showIDs := os.Getenv("DOCKER_COMPLETION_SHOW_NODE_IDS") == "yes"
return func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
list, err := dockerCLI.Client().NodeList(cmd.Context(), swarm.NodeListOptions{})
list, err := dockerCLI.Client().NodeList(cmd.Context(), client.NodeListOptions{})
if err != nil {
return nil, cobra.ShellCompDirectiveError
}

View File

@@ -11,8 +11,8 @@ import (
flagsHelper "github.com/docker/cli/cli/flags"
"github.com/docker/cli/opts"
"github.com/fvbommel/sortorder"
"github.com/moby/moby/api/types/swarm"
"github.com/moby/moby/api/types/system"
"github.com/moby/moby/client"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
)
@@ -53,7 +53,7 @@ func newListCommand(dockerCli command.Cli) *cobra.Command {
func runList(ctx context.Context, dockerCLI command.Cli, options listOptions) error {
apiClient := dockerCLI.Client()
nodes, err := apiClient.NodeList(ctx, swarm.NodeListOptions{
nodes, err := apiClient.NodeList(ctx, client.NodeListOptions{
Filters: options.filter.Value(),
})
if err != nil {

View File

@@ -11,6 +11,7 @@ import (
"github.com/docker/cli/cli/command/task"
"github.com/docker/cli/opts"
"github.com/moby/moby/api/types/swarm"
"github.com/moby/moby/client"
"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
@@ -83,7 +84,7 @@ func runPs(ctx context.Context, dockerCLI command.Cli, options psOptions) error
filter := options.filter.Value()
filter.Add("node", node.ID)
nodeTasks, err := apiClient.TaskList(ctx, swarm.TaskListOptions{Filters: filter})
nodeTasks, err := apiClient.TaskList(ctx, client.TaskListOptions{Filters: filter})
if err != nil {
errs = append(errs, err.Error())
continue

View File

@@ -12,6 +12,7 @@ import (
"github.com/docker/cli/internal/test/builders"
"github.com/moby/moby/api/types/swarm"
"github.com/moby/moby/api/types/system"
"github.com/moby/moby/client"
"gotest.tools/v3/assert"
"gotest.tools/v3/golden"
)
@@ -22,7 +23,7 @@ func TestNodePsErrors(t *testing.T) {
flags map[string]string
infoFunc func() (system.Info, error)
nodeInspectFunc func() (swarm.Node, []byte, error)
taskListFunc func(options swarm.TaskListOptions) ([]swarm.Task, error)
taskListFunc func(options client.TaskListOptions) ([]swarm.Task, error)
taskInspectFunc func(taskID string) (swarm.Task, []byte, error)
expectedError string
}{
@@ -41,7 +42,7 @@ func TestNodePsErrors(t *testing.T) {
},
{
args: []string{"nodeID"},
taskListFunc: func(options swarm.TaskListOptions) ([]swarm.Task, error) {
taskListFunc: func(options client.TaskListOptions) ([]swarm.Task, error) {
return []swarm.Task{}, errors.New("error returning the task list")
},
expectedError: "error returning the task list",
@@ -72,9 +73,9 @@ func TestNodePs(t *testing.T) {
flags map[string]string
infoFunc func() (system.Info, error)
nodeInspectFunc func() (swarm.Node, []byte, error)
taskListFunc func(options swarm.TaskListOptions) ([]swarm.Task, error)
taskListFunc func(options client.TaskListOptions) ([]swarm.Task, error)
taskInspectFunc func(taskID string) (swarm.Task, []byte, error)
serviceInspectFunc func(ctx context.Context, serviceID string, opts swarm.ServiceInspectOptions) (swarm.Service, []byte, error)
serviceInspectFunc func(ctx context.Context, serviceID string, opts client.ServiceInspectOptions) (swarm.Service, []byte, error)
}{
{
name: "simple",
@@ -82,7 +83,7 @@ func TestNodePs(t *testing.T) {
nodeInspectFunc: func() (swarm.Node, []byte, error) {
return *builders.Node(), []byte{}, nil
},
taskListFunc: func(options swarm.TaskListOptions) ([]swarm.Task, error) {
taskListFunc: func(options client.TaskListOptions) ([]swarm.Task, error) {
return []swarm.Task{
*builders.Task(builders.WithStatus(builders.Timestamp(time.Now().Add(-2*time.Hour)), builders.PortStatus([]swarm.PortConfig{
{
@@ -93,7 +94,7 @@ func TestNodePs(t *testing.T) {
}))),
}, nil
},
serviceInspectFunc: func(ctx context.Context, serviceID string, opts swarm.ServiceInspectOptions) (swarm.Service, []byte, error) {
serviceInspectFunc: func(ctx context.Context, serviceID string, opts client.ServiceInspectOptions) (swarm.Service, []byte, error) {
return swarm.Service{
ID: serviceID,
Spec: swarm.ServiceSpec{
@@ -110,7 +111,7 @@ func TestNodePs(t *testing.T) {
nodeInspectFunc: func() (swarm.Node, []byte, error) {
return *builders.Node(), []byte{}, nil
},
taskListFunc: func(options swarm.TaskListOptions) ([]swarm.Task, error) {
taskListFunc: func(options client.TaskListOptions) ([]swarm.Task, error) {
return []swarm.Task{
*builders.Task(builders.TaskID("taskID1"), builders.TaskServiceID("failure"),
builders.WithStatus(builders.Timestamp(time.Now().Add(-2*time.Hour)), builders.StatusErr("a task error"))),
@@ -120,7 +121,7 @@ func TestNodePs(t *testing.T) {
builders.WithStatus(builders.Timestamp(time.Now().Add(-4*time.Hour)), builders.StatusErr("a task error"))),
}, nil
},
serviceInspectFunc: func(ctx context.Context, serviceID string, opts swarm.ServiceInspectOptions) (swarm.Service, []byte, error) {
serviceInspectFunc: func(ctx context.Context, serviceID string, opts client.ServiceInspectOptions) (swarm.Service, []byte, error) {
return swarm.Service{
ID: serviceID,
Spec: swarm.ServiceSpec{

View File

@@ -7,7 +7,7 @@ import (
"github.com/docker/cli/cli"
"github.com/docker/cli/cli/command"
"github.com/moby/moby/api/types/swarm"
"github.com/moby/moby/client"
"github.com/spf13/cobra"
)
@@ -38,7 +38,7 @@ func runRemove(ctx context.Context, dockerCLI command.Cli, nodeIDs []string, opt
var errs []error
for _, id := range nodeIDs {
if err := apiClient.NodeRemove(ctx, id, swarm.NodeRemoveOptions{Force: opts.force}); err != nil {
if err := apiClient.NodeRemove(ctx, id, client.NodeRemoveOptions{Force: opts.force}); err != nil {
errs = append(errs, err)
continue
}

View File

@@ -16,6 +16,7 @@ import (
"github.com/docker/cli/cli/streams"
"github.com/docker/cli/internal/prompt"
"github.com/docker/cli/internal/tui"
"github.com/moby/moby/api/pkg/authconfig"
registrytypes "github.com/moby/moby/api/types/registry"
"github.com/morikuni/aec"
)
@@ -58,19 +59,19 @@ func GetDefaultAuthConfig(cfg *configfile.ConfigFile, checkCredStore bool, serve
if !isDefaultRegistry {
serverAddress = credentials.ConvertToHostname(serverAddress)
}
authconfig := configtypes.AuthConfig{}
authCfg := configtypes.AuthConfig{}
var err error
if checkCredStore {
authconfig, err = cfg.GetAuthConfig(serverAddress)
authCfg, err = cfg.GetAuthConfig(serverAddress)
if err != nil {
return registrytypes.AuthConfig{
ServerAddress: serverAddress,
}, err
}
}
authconfig.ServerAddress = serverAddress
authconfig.IdentityToken = ""
return registrytypes.AuthConfig(authconfig), nil
authCfg.ServerAddress = serverAddress
authCfg.IdentityToken = ""
return registrytypes.AuthConfig(authCfg), nil
}
// PromptUserForCredentials handles the CLI prompt for the user to input
@@ -185,7 +186,7 @@ func RetrieveAuthTokenFromImage(cfg *configfile.ConfigFile, image string) (strin
return "", err
}
encodedAuth, err := registrytypes.EncodeAuthConfig(registrytypes.AuthConfig(authConfig))
encodedAuth, err := authconfig.Encode(registrytypes.AuthConfig(authConfig))
if err != nil {
return "", err
}

View File

@@ -10,7 +10,9 @@ import (
"github.com/docker/cli/cli/command/formatter"
"github.com/docker/cli/internal/commands"
"github.com/docker/cli/opts"
"github.com/moby/moby/api/pkg/authconfig"
registrytypes "github.com/moby/moby/api/types/registry"
"github.com/moby/moby/client"
"github.com/spf13/cobra"
)
@@ -62,7 +64,7 @@ func runSearch(ctx context.Context, dockerCli command.Cli, options searchOptions
return err
}
results, err := dockerCli.Client().ImageSearch(ctx, options.term, registrytypes.SearchOptions{
results, err := dockerCli.Client().ImageSearch(ctx, options.term, client.ImageSearchOptions{
RegistryAuth: encodedAuth,
PrivilegeFunc: nil,
Filters: options.filter.Value(),
@@ -100,7 +102,7 @@ func getAuth(dockerCLI command.Cli, reposName string) (encodedAuth string, err e
// "no credentials found"). We'll get an error when search failed,
// so fine to ignore in most situations.
authConfig, _ := dockerCLI.ConfigFile().GetAuthConfig(authCfgKey)
return registrytypes.EncodeAuthConfig(registrytypes.AuthConfig(authConfig))
return authconfig.Encode(registrytypes.AuthConfig(authConfig))
}
// splitReposSearchTerm breaks a search term into an index name and remote name

View File

@@ -8,6 +8,7 @@ import (
"github.com/docker/cli/cli/command"
"github.com/docker/cli/cli/config/configfile"
configtypes "github.com/docker/cli/cli/config/types"
"github.com/moby/moby/api/pkg/authconfig"
"github.com/moby/moby/api/types/registry"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
@@ -58,14 +59,14 @@ func TestGetDefaultAuthConfig(t *testing.T) {
},
}
cfg := configfile.New("filename")
for _, authconfig := range testAuthConfigs {
assert.Check(t, cfg.GetCredentialsStore(authconfig.ServerAddress).Store(configtypes.AuthConfig(authconfig)))
for _, authCfg := range testAuthConfigs {
assert.Check(t, cfg.GetCredentialsStore(authCfg.ServerAddress).Store(configtypes.AuthConfig(authCfg)))
}
for _, tc := range testCases {
serverAddress := tc.inputServerAddress
authconfig, err := command.GetDefaultAuthConfig(cfg, tc.checkCredStore, serverAddress, serverAddress == "https://index.docker.io/v1/")
authCfg, err := command.GetDefaultAuthConfig(cfg, tc.checkCredStore, serverAddress, serverAddress == "https://index.docker.io/v1/")
assert.NilError(t, err)
assert.Check(t, is.DeepEqual(tc.expectedAuthConfig, authconfig))
assert.Check(t, is.DeepEqual(tc.expectedAuthConfig, authCfg))
}
}
@@ -78,8 +79,8 @@ func TestGetDefaultAuthConfig_HelperError(t *testing.T) {
ServerAddress: serverAddress,
}
const isDefaultRegistry = false // registry is not "https://index.docker.io/v1/"
authconfig, err := command.GetDefaultAuthConfig(cfg, true, serverAddress, isDefaultRegistry)
assert.Check(t, is.DeepEqual(expectedAuthConfig, authconfig))
authCfg, err := command.GetDefaultAuthConfig(cfg, true, serverAddress, isDefaultRegistry)
assert.Check(t, is.DeepEqual(expectedAuthConfig, authCfg))
assert.Check(t, is.ErrorContains(err, "docker-credential-fake-does-not-exist"))
}
@@ -185,7 +186,7 @@ func TestRetrieveAuthTokenFromImage(t *testing.T) {
imageRef := path.Join(tc.prefix, remoteRef)
actual, err := command.RetrieveAuthTokenFromImage(&cfg, imageRef)
assert.NilError(t, err)
expectedAuthCfg, err := registry.EncodeAuthConfig(tc.expectedAuthCfg)
expectedAuthCfg, err := authconfig.Encode(tc.expectedAuthCfg)
assert.NilError(t, err)
assert.Equal(t, actual, expectedAuthCfg)
}

View File

@@ -12,30 +12,30 @@ import (
type fakeClient struct {
client.Client
serviceInspectWithRawFunc func(ctx context.Context, serviceID string, options swarm.ServiceInspectOptions) (swarm.Service, []byte, error)
serviceUpdateFunc func(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options swarm.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error)
serviceListFunc func(context.Context, swarm.ServiceListOptions) ([]swarm.Service, error)
taskListFunc func(context.Context, swarm.TaskListOptions) ([]swarm.Task, error)
serviceInspectWithRawFunc func(ctx context.Context, serviceID string, options client.ServiceInspectOptions) (swarm.Service, []byte, error)
serviceUpdateFunc func(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options client.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error)
serviceListFunc func(context.Context, client.ServiceListOptions) ([]swarm.Service, error)
taskListFunc func(context.Context, client.TaskListOptions) ([]swarm.Task, error)
infoFunc func(ctx context.Context) (system.Info, error)
networkInspectFunc func(ctx context.Context, networkID string, options network.InspectOptions) (network.Inspect, error)
nodeListFunc func(ctx context.Context, options swarm.NodeListOptions) ([]swarm.Node, error)
networkInspectFunc func(ctx context.Context, networkID string, options client.NetworkInspectOptions) (network.Inspect, error)
nodeListFunc func(ctx context.Context, options client.NodeListOptions) ([]swarm.Node, error)
}
func (f *fakeClient) NodeList(ctx context.Context, options swarm.NodeListOptions) ([]swarm.Node, error) {
func (f *fakeClient) NodeList(ctx context.Context, options client.NodeListOptions) ([]swarm.Node, error) {
if f.nodeListFunc != nil {
return f.nodeListFunc(ctx, options)
}
return nil, nil
}
func (f *fakeClient) TaskList(ctx context.Context, options swarm.TaskListOptions) ([]swarm.Task, error) {
func (f *fakeClient) TaskList(ctx context.Context, options client.TaskListOptions) ([]swarm.Task, error) {
if f.taskListFunc != nil {
return f.taskListFunc(ctx, options)
}
return nil, nil
}
func (f *fakeClient) ServiceInspectWithRaw(ctx context.Context, serviceID string, options swarm.ServiceInspectOptions) (swarm.Service, []byte, error) {
func (f *fakeClient) ServiceInspectWithRaw(ctx context.Context, serviceID string, options client.ServiceInspectOptions) (swarm.Service, []byte, error) {
if f.serviceInspectWithRawFunc != nil {
return f.serviceInspectWithRawFunc(ctx, serviceID, options)
}
@@ -43,7 +43,7 @@ func (f *fakeClient) ServiceInspectWithRaw(ctx context.Context, serviceID string
return *builders.Service(builders.ServiceID(serviceID)), []byte{}, nil
}
func (f *fakeClient) ServiceList(ctx context.Context, options swarm.ServiceListOptions) ([]swarm.Service, error) {
func (f *fakeClient) ServiceList(ctx context.Context, options client.ServiceListOptions) ([]swarm.Service, error) {
if f.serviceListFunc != nil {
return f.serviceListFunc(ctx, options)
}
@@ -51,7 +51,7 @@ func (f *fakeClient) ServiceList(ctx context.Context, options swarm.ServiceListO
return nil, nil
}
func (f *fakeClient) ServiceUpdate(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options swarm.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error) {
func (f *fakeClient) ServiceUpdate(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options client.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error) {
if f.serviceUpdateFunc != nil {
return f.serviceUpdateFunc(ctx, serviceID, version, service, options)
}
@@ -66,7 +66,7 @@ func (f *fakeClient) Info(ctx context.Context) (system.Info, error) {
return f.infoFunc(ctx)
}
func (f *fakeClient) NetworkInspect(ctx context.Context, networkID string, options network.InspectOptions) (network.Inspect, error) {
func (f *fakeClient) NetworkInspect(ctx context.Context, networkID string, options client.NetworkInspectOptions) (network.Inspect, error) {
if f.networkInspectFunc != nil {
return f.networkInspectFunc(ctx, networkID, options)
}

View File

@@ -4,7 +4,7 @@ import (
"os"
"github.com/docker/cli/cli/command/completion"
"github.com/moby/moby/api/types/swarm"
"github.com/moby/moby/client"
"github.com/spf13/cobra"
)
@@ -15,7 +15,7 @@ func completeServiceNames(dockerCLI completion.APIClientProvider) cobra.Completi
// https://github.com/docker/cli/blob/f9ced58158d5e0b358052432244b483774a1983d/contrib/completion/bash/docker#L41-L43
showIDs := os.Getenv("DOCKER_COMPLETION_SHOW_SERVICE_IDS") == "yes"
return func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
list, err := dockerCLI.Client().ServiceList(cmd.Context(), swarm.ServiceListOptions{})
list, err := dockerCLI.Client().ServiceList(cmd.Context(), client.ServiceListOptions{})
if err != nil {
return nil, cobra.ShellCompDirectiveError
}

View File

@@ -101,7 +101,7 @@ func newCreateCommand(dockerCLI command.Cli) *cobra.Command {
func runCreate(ctx context.Context, dockerCLI command.Cli, flags *pflag.FlagSet, opts *serviceOptions) error {
apiClient := dockerCLI.Client()
createOpts := swarm.ServiceCreateOptions{}
createOpts := client.ServiceCreateOptions{}
service, err := opts.ToService(ctx, apiClient, flags)
if err != nil {

View File

@@ -6,6 +6,7 @@ import (
"github.com/docker/cli/opts/swarmopts"
"github.com/moby/moby/api/types/swarm"
"github.com/moby/moby/client"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
)
@@ -13,9 +14,9 @@ import (
// fakeConfigAPIClientList is used to let us pass a closure as a
// ConfigAPIClient, to use as ConfigList. for all the other methods in the
// interface, it does nothing, not even return an error, so don't use them
type fakeConfigAPIClientList func(context.Context, swarm.ConfigListOptions) ([]swarm.Config, error)
type fakeConfigAPIClientList func(context.Context, client.ConfigListOptions) ([]swarm.Config, error)
func (f fakeConfigAPIClientList) ConfigList(ctx context.Context, opts swarm.ConfigListOptions) ([]swarm.Config, error) {
func (f fakeConfigAPIClientList) ConfigList(ctx context.Context, opts client.ConfigListOptions) ([]swarm.Config, error) {
return f(ctx, opts)
}
@@ -66,7 +67,7 @@ func TestSetConfigsWithCredSpecAndConfigs(t *testing.T) {
}
// set up a function to use as the list function
var fakeClient fakeConfigAPIClientList = func(_ context.Context, opts swarm.ConfigListOptions) ([]swarm.Config, error) {
var fakeClient fakeConfigAPIClientList = func(_ context.Context, opts client.ConfigListOptions) ([]swarm.Config, error) {
f := opts.Filters
// we're expecting the filter to have names "foo" and "bar"
@@ -146,7 +147,7 @@ func TestSetConfigsOnlyCredSpec(t *testing.T) {
}
// set up a function to use as the list function
var fakeClient fakeConfigAPIClientList = func(_ context.Context, opts swarm.ConfigListOptions) ([]swarm.Config, error) {
var fakeClient fakeConfigAPIClientList = func(_ context.Context, opts client.ConfigListOptions) ([]swarm.Config, error) {
f := opts.Filters
names := f.Get("name")
@@ -197,7 +198,7 @@ func TestSetConfigsOnlyConfigs(t *testing.T) {
},
}
var fakeClient fakeConfigAPIClientList = func(_ context.Context, opts swarm.ConfigListOptions) ([]swarm.Config, error) {
var fakeClient fakeConfigAPIClientList = func(_ context.Context, opts client.ConfigListOptions) ([]swarm.Config, error) {
f := opts.Filters
names := f.Get("name")
@@ -258,7 +259,7 @@ func TestSetConfigsNoConfigs(t *testing.T) {
},
}
var fakeClient fakeConfigAPIClientList = func(_ context.Context, opts swarm.ConfigListOptions) ([]swarm.Config, error) {
var fakeClient fakeConfigAPIClientList = func(_ context.Context, opts client.ConfigListOptions) ([]swarm.Config, error) {
// assert false -- we should never call this function
assert.Assert(t, false, "we should not be listing configs")
return nil, nil

View File

@@ -13,8 +13,7 @@ import (
"github.com/docker/cli/cli/command/completion"
"github.com/docker/cli/cli/command/formatter"
flagsHelper "github.com/docker/cli/cli/flags"
"github.com/moby/moby/api/types/network"
"github.com/moby/moby/api/types/swarm"
"github.com/moby/moby/client"
"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
@@ -66,7 +65,7 @@ func runInspect(ctx context.Context, dockerCLI command.Cli, opts inspectOptions)
getRef := func(ref string) (any, []byte, error) {
// Service inspect shows defaults values in empty fields.
service, _, err := apiClient.ServiceInspectWithRaw(ctx, ref, swarm.ServiceInspectOptions{InsertDefaults: true})
service, _, err := apiClient.ServiceInspectWithRaw(ctx, ref, client.ServiceInspectOptions{InsertDefaults: true})
if err == nil || !errdefs.IsNotFound(err) {
return service, nil, err
}
@@ -74,7 +73,7 @@ func runInspect(ctx context.Context, dockerCLI command.Cli, opts inspectOptions)
}
getNetwork := func(ref string) (any, []byte, error) {
nw, _, err := apiClient.NetworkInspectWithRaw(ctx, ref, network.InspectOptions{Scope: "swarm"})
nw, _, err := apiClient.NetworkInspectWithRaw(ctx, ref, client.NetworkInspectOptions{Scope: "swarm"})
if err == nil || !errdefs.IsNotFound(err) {
return nw, nil, err
}

View File

@@ -56,7 +56,7 @@ func runList(ctx context.Context, dockerCLI command.Cli, options listOptions) er
err error
)
listOpts := swarm.ServiceListOptions{
listOpts := client.ServiceListOptions{
Filters: options.filter.Value(),
// When not running "quiet", also get service status (number of running
// and desired tasks). Note that this is only supported on API v1.41 and
@@ -146,7 +146,7 @@ func AppendServiceStatus(ctx context.Context, c client.APIClient, services []swa
return services, nil
}
tasks, err := c.TaskList(ctx, swarm.TaskListOptions{Filters: taskFilter})
tasks, err := c.TaskList(ctx, client.TaskListOptions{Filters: taskFilter})
if err != nil {
return nil, err
}
@@ -183,7 +183,7 @@ func AppendServiceStatus(ctx context.Context, c client.APIClient, services []swa
}
func getActiveNodes(ctx context.Context, c client.NodeAPIClient) (map[string]struct{}, error) {
nodes, err := c.NodeList(ctx, swarm.NodeListOptions{})
nodes, err := c.NodeList(ctx, client.NodeListOptions{})
if err != nil {
return nil, err
}

View File

@@ -11,6 +11,7 @@ import (
"github.com/docker/cli/internal/test/builders"
"github.com/moby/moby/api/types/swarm"
"github.com/moby/moby/api/types/versions"
"github.com/moby/moby/client"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
"gotest.tools/v3/golden"
@@ -18,7 +19,7 @@ import (
func TestServiceListOrder(t *testing.T) {
cli := test.NewFakeCli(&fakeClient{
serviceListFunc: func(ctx context.Context, options swarm.ServiceListOptions) ([]swarm.Service, error) {
serviceListFunc: func(ctx context.Context, options client.ServiceListOptions) ([]swarm.Service, error) {
return []swarm.Service{
newService("a57dbe8", "service-1-foo"),
newService("a57dbdd", "service-10-foo"),
@@ -172,7 +173,7 @@ func TestServiceListServiceStatus(t *testing.T) {
tc.cluster = generateCluster(t, tc.opts)
}
cli := test.NewFakeCli(&fakeClient{
serviceListFunc: func(ctx context.Context, options swarm.ServiceListOptions) ([]swarm.Service, error) {
serviceListFunc: func(ctx context.Context, options client.ServiceListOptions) ([]swarm.Service, error) {
if !options.Status || versions.LessThan(tc.opts.apiVersion, "1.41") {
// Don't return "ServiceStatus" if not requested, or on older API versions
for i := range tc.cluster.services {
@@ -181,10 +182,10 @@ func TestServiceListServiceStatus(t *testing.T) {
}
return tc.cluster.services, nil
},
taskListFunc: func(context.Context, swarm.TaskListOptions) ([]swarm.Task, error) {
taskListFunc: func(context.Context, client.TaskListOptions) ([]swarm.Task, error) {
return tc.cluster.tasks, nil
},
nodeListFunc: func(ctx context.Context, options swarm.NodeListOptions) ([]swarm.Node, error) {
nodeListFunc: func(ctx context.Context, options client.NodeListOptions) ([]swarm.Node, error) {
return tc.cluster.nodes, nil
},
})

View File

@@ -90,7 +90,7 @@ func runLogs(ctx context.Context, dockerCli command.Cli, opts *logsOptions) erro
logfunc func(context.Context, string, container.LogsOptions) (io.ReadCloser, error)
)
service, _, err := apiClient.ServiceInspectWithRaw(ctx, opts.target, swarm.ServiceInspectOptions{})
service, _, err := apiClient.ServiceInspectWithRaw(ctx, opts.target, client.ServiceInspectOptions{})
if err != nil {
// if it's any error other than service not found, it's Real
if !errdefs.IsNotFound(err) {

View File

@@ -16,7 +16,6 @@ import (
gogotypes "github.com/gogo/protobuf/types"
"github.com/google/shlex"
"github.com/moby/moby/api/types/container"
"github.com/moby/moby/api/types/network"
"github.com/moby/moby/api/types/swarm"
"github.com/moby/moby/client"
"github.com/moby/swarmkit/v2/api"
@@ -400,8 +399,11 @@ func (c *credentialSpecOpt) Value() *swarm.CredentialSpec {
}
func resolveNetworkID(ctx context.Context, apiClient client.NetworkAPIClient, networkIDOrName string) (string, error) {
nw, err := apiClient.NetworkInspect(ctx, networkIDOrName, network.InspectOptions{Scope: "swarm"})
return nw.ID, err
nw, err := apiClient.NetworkInspect(ctx, networkIDOrName, client.NetworkInspectOptions{Scope: "swarm"})
if err != nil {
return "", err
}
return nw.ID, nil
}
func convertNetworks(networks opts.NetworkOpt) []swarm.NetworkAttachmentConfig {

View File

@@ -10,6 +10,7 @@ import (
"github.com/moby/moby/api/types/container"
"github.com/moby/moby/api/types/network"
"github.com/moby/moby/api/types/swarm"
"github.com/moby/moby/client"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
)
@@ -191,7 +192,7 @@ func TestToServiceNetwork(t *testing.T) {
}
apiClient := &fakeClient{
networkInspectFunc: func(ctx context.Context, networkID string, options network.InspectOptions) (network.Inspect, error) {
networkInspectFunc: func(ctx context.Context, networkID string, options client.NetworkInspectOptions) (network.Inspect, error) {
for _, nw := range nws {
if nw.ID == networkID || nw.Name == networkID {
return nw, nil

View File

@@ -4,25 +4,25 @@ import (
"context"
"github.com/moby/moby/api/types/filters"
swarmtypes "github.com/moby/moby/api/types/swarm"
"github.com/moby/moby/api/types/swarm"
"github.com/moby/moby/client"
"github.com/pkg/errors"
)
// ParseSecrets retrieves the secrets with the requested names and fills
// secret IDs into the secret references.
func ParseSecrets(ctx context.Context, apiClient client.SecretAPIClient, requestedSecrets []*swarmtypes.SecretReference) ([]*swarmtypes.SecretReference, error) {
func ParseSecrets(ctx context.Context, apiClient client.SecretAPIClient, requestedSecrets []*swarm.SecretReference) ([]*swarm.SecretReference, error) {
if len(requestedSecrets) == 0 {
return []*swarmtypes.SecretReference{}, nil
return []*swarm.SecretReference{}, nil
}
secretRefs := make(map[string]*swarmtypes.SecretReference)
secretRefs := make(map[string]*swarm.SecretReference)
for _, secret := range requestedSecrets {
if _, exists := secretRefs[secret.File.Name]; exists {
return nil, errors.Errorf("duplicate secret target for %s not allowed", secret.SecretName)
}
secretRef := new(swarmtypes.SecretReference)
secretRef := new(swarm.SecretReference)
*secretRef = *secret
secretRefs[secret.File.Name] = secretRef
}
@@ -32,7 +32,7 @@ func ParseSecrets(ctx context.Context, apiClient client.SecretAPIClient, request
args.Add("name", s.SecretName)
}
secrets, err := apiClient.SecretList(ctx, swarmtypes.SecretListOptions{
secrets, err := apiClient.SecretList(ctx, swarm.SecretListOptions{
Filters: args,
})
if err != nil {
@@ -44,7 +44,7 @@ func ParseSecrets(ctx context.Context, apiClient client.SecretAPIClient, request
foundSecrets[secret.Spec.Annotations.Name] = secret.ID
}
addedSecrets := []*swarmtypes.SecretReference{}
addedSecrets := []*swarm.SecretReference{}
for _, ref := range secretRefs {
id, ok := foundSecrets[ref.SecretName]
@@ -63,9 +63,9 @@ func ParseSecrets(ctx context.Context, apiClient client.SecretAPIClient, request
// ParseConfigs retrieves the configs from the requested names and converts
// them to config references to use with the spec
func ParseConfigs(ctx context.Context, apiClient client.ConfigAPIClient, requestedConfigs []*swarmtypes.ConfigReference) ([]*swarmtypes.ConfigReference, error) {
func ParseConfigs(ctx context.Context, apiClient client.ConfigAPIClient, requestedConfigs []*swarm.ConfigReference) ([]*swarm.ConfigReference, error) {
if len(requestedConfigs) == 0 {
return []*swarmtypes.ConfigReference{}, nil
return []*swarm.ConfigReference{}, nil
}
// the configRefs map has two purposes: it prevents duplication of config
@@ -79,12 +79,12 @@ func ParseConfigs(ctx context.Context, apiClient client.ConfigAPIClient, request
// are in use for the same Config, and we should deduplicate
// such ConfigReferences, as no matter how many times the Config is used,
// it is only needed to be referenced once.
configRefs := make(map[string]*swarmtypes.ConfigReference)
runtimeRefs := make(map[string]*swarmtypes.ConfigReference)
configRefs := make(map[string]*swarm.ConfigReference)
runtimeRefs := make(map[string]*swarm.ConfigReference)
for _, config := range requestedConfigs {
// copy the config, so we don't mutate the args
configRef := new(swarmtypes.ConfigReference)
configRef := new(swarm.ConfigReference)
*configRef = *config
if config.Runtime != nil {
@@ -112,7 +112,7 @@ func ParseConfigs(ctx context.Context, apiClient client.ConfigAPIClient, request
args.Add("name", s.ConfigName)
}
configs, err := apiClient.ConfigList(ctx, swarmtypes.ConfigListOptions{
configs, err := apiClient.ConfigList(ctx, client.ConfigListOptions{
Filters: args,
})
if err != nil {
@@ -124,7 +124,7 @@ func ParseConfigs(ctx context.Context, apiClient client.ConfigAPIClient, request
foundConfigs[config.Spec.Annotations.Name] = config.ID
}
addedConfigs := []*swarmtypes.ConfigReference{}
addedConfigs := []*swarm.ConfigReference{}
for _, ref := range configRefs {
id, ok := foundConfigs[ref.ConfigName]

View File

@@ -88,7 +88,7 @@ func ServiceProgress(ctx context.Context, apiClient client.APIClient, serviceID
)
for {
service, _, err := apiClient.ServiceInspectWithRaw(ctx, serviceID, swarm.ServiceInspectOptions{})
service, _, err := apiClient.ServiceInspectWithRaw(ctx, serviceID, client.ServiceInspectOptions{})
if err != nil {
return err
}
@@ -142,7 +142,7 @@ func ServiceProgress(ctx context.Context, apiClient client.APIClient, serviceID
return nil
}
tasks, err := apiClient.TaskList(ctx, swarm.TaskListOptions{Filters: filters.NewArgs(
tasks, err := apiClient.TaskList(ctx, client.TaskListOptions{Filters: filters.NewArgs(
filters.KeyValuePair{Key: "service", Value: service.ID},
filters.KeyValuePair{Key: "_up-to-date", Value: "true"},
)})
@@ -216,7 +216,7 @@ func ServiceProgress(ctx context.Context, apiClient client.APIClient, serviceID
//
// TODO(thaJeztah): this should really be a filter on [apiClient.NodeList] instead of being filtered on the client side.
func getActiveNodes(ctx context.Context, apiClient client.NodeAPIClient) (map[string]struct{}, error) {
nodes, err := apiClient.NodeList(ctx, swarm.NodeListOptions{})
nodes, err := apiClient.NodeList(ctx, client.NodeListOptions{})
if err != nil {
return nil, err
}

View File

@@ -12,7 +12,6 @@ import (
"github.com/docker/cli/cli/command/task"
"github.com/docker/cli/opts"
"github.com/moby/moby/api/types/filters"
"github.com/moby/moby/api/types/swarm"
"github.com/moby/moby/client"
"github.com/pkg/errors"
"github.com/spf13/cobra"
@@ -68,7 +67,7 @@ func runPS(ctx context.Context, dockerCli command.Cli, options psOptions) error
return err
}
tasks, err := apiClient.TaskList(ctx, swarm.TaskListOptions{Filters: filter})
tasks, err := apiClient.TaskList(ctx, client.TaskListOptions{Filters: filter})
if err != nil {
return err
}
@@ -98,11 +97,11 @@ func createFilter(ctx context.Context, apiClient client.APIClient, options psOpt
serviceIDFilter.Add("id", service)
serviceNameFilter.Add("name", service)
}
serviceByIDList, err := apiClient.ServiceList(ctx, swarm.ServiceListOptions{Filters: serviceIDFilter})
serviceByIDList, err := apiClient.ServiceList(ctx, client.ServiceListOptions{Filters: serviceIDFilter})
if err != nil {
return filter, nil, err
}
serviceByNameList, err := apiClient.ServiceList(ctx, swarm.ServiceListOptions{Filters: serviceNameFilter})
serviceByNameList, err := apiClient.ServiceList(ctx, client.ServiceListOptions{Filters: serviceNameFilter})
if err != nil {
return filter, nil, err
}

View File

@@ -10,13 +10,14 @@ import (
"github.com/moby/moby/api/types/filters"
"github.com/moby/moby/api/types/swarm"
"github.com/moby/moby/api/types/system"
"github.com/moby/moby/client"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
)
func TestCreateFilter(t *testing.T) {
apiClient := &fakeClient{
serviceListFunc: func(ctx context.Context, options swarm.ServiceListOptions) ([]swarm.Service, error) {
serviceListFunc: func(ctx context.Context, options client.ServiceListOptions) ([]swarm.Service, error) {
return []swarm.Service{
{ID: "idmatch"},
{ID: "idprefixmatch"},
@@ -48,7 +49,7 @@ func TestCreateFilter(t *testing.T) {
func TestCreateFilterWithAmbiguousIDPrefixError(t *testing.T) {
apiClient := &fakeClient{
serviceListFunc: func(ctx context.Context, options swarm.ServiceListOptions) ([]swarm.Service, error) {
serviceListFunc: func(ctx context.Context, options client.ServiceListOptions) ([]swarm.Service, error) {
return []swarm.Service{
{ID: "aaaone"},
{ID: "aaatwo"},
@@ -75,7 +76,7 @@ func TestCreateFilterNoneFound(t *testing.T) {
func TestRunPSWarnsOnNotFound(t *testing.T) {
apiClient := &fakeClient{
serviceListFunc: func(ctx context.Context, options swarm.ServiceListOptions) ([]swarm.Service, error) {
serviceListFunc: func(ctx context.Context, options client.ServiceListOptions) ([]swarm.Service, error) {
return []swarm.Service{
{ID: "foo"},
}, nil
@@ -96,10 +97,10 @@ func TestRunPSWarnsOnNotFound(t *testing.T) {
func TestRunPSQuiet(t *testing.T) {
apiClient := &fakeClient{
serviceListFunc: func(ctx context.Context, options swarm.ServiceListOptions) ([]swarm.Service, error) {
serviceListFunc: func(ctx context.Context, options client.ServiceListOptions) ([]swarm.Service, error) {
return []swarm.Service{{ID: "foo"}}, nil
},
taskListFunc: func(ctx context.Context, options swarm.TaskListOptions) ([]swarm.Task, error) {
taskListFunc: func(ctx context.Context, options client.TaskListOptions) ([]swarm.Task, error) {
return []swarm.Task{{ID: "sxabyp0obqokwekpun4rjo0b3"}}, nil
},
}

View File

@@ -7,8 +7,8 @@ import (
"github.com/docker/cli/cli"
"github.com/docker/cli/cli/command"
"github.com/docker/cli/cli/command/completion"
"github.com/moby/moby/api/types/swarm"
"github.com/moby/moby/api/types/versions"
"github.com/moby/moby/client"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
)
@@ -43,12 +43,12 @@ func newRollbackCommand(dockerCli command.Cli) *cobra.Command {
func runRollback(ctx context.Context, dockerCLI command.Cli, options *serviceOptions, serviceID string) error {
apiClient := dockerCLI.Client()
service, _, err := apiClient.ServiceInspectWithRaw(ctx, serviceID, swarm.ServiceInspectOptions{})
service, _, err := apiClient.ServiceInspectWithRaw(ctx, serviceID, client.ServiceInspectOptions{})
if err != nil {
return err
}
response, err := apiClient.ServiceUpdate(ctx, service.ID, service.Version, service.Spec, swarm.ServiceUpdateOptions{
response, err := apiClient.ServiceUpdate(ctx, service.ID, service.Version, service.Spec, client.ServiceUpdateOptions{
Rollback: "previous", // TODO(thaJeztah): this should have a const defined
})
if err != nil {

View File

@@ -9,6 +9,7 @@ import (
"github.com/docker/cli/internal/test"
"github.com/moby/moby/api/types/swarm"
"github.com/moby/moby/client"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
)
@@ -17,7 +18,7 @@ func TestRollback(t *testing.T) {
testCases := []struct {
name string
args []string
serviceUpdateFunc func(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options swarm.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error)
serviceUpdateFunc func(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options client.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error)
expectedDockerCliErr string
}{
{
@@ -27,7 +28,7 @@ func TestRollback(t *testing.T) {
{
name: "rollback-service-with-warnings",
args: []string{"service-id"},
serviceUpdateFunc: func(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options swarm.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error) {
serviceUpdateFunc: func(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options client.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error) {
response := swarm.ServiceUpdateResponse{}
response.Warnings = []string{
@@ -58,8 +59,8 @@ func TestRollbackWithErrors(t *testing.T) {
testCases := []struct {
name string
args []string
serviceInspectWithRawFunc func(ctx context.Context, serviceID string, options swarm.ServiceInspectOptions) (swarm.Service, []byte, error)
serviceUpdateFunc func(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options swarm.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error)
serviceInspectWithRawFunc func(ctx context.Context, serviceID string, options client.ServiceInspectOptions) (swarm.Service, []byte, error)
serviceUpdateFunc func(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, opts client.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error)
expectedError string
}{
{
@@ -74,7 +75,7 @@ func TestRollbackWithErrors(t *testing.T) {
{
name: "service-does-not-exists",
args: []string{"service-id"},
serviceInspectWithRawFunc: func(ctx context.Context, serviceID string, options swarm.ServiceInspectOptions) (swarm.Service, []byte, error) {
serviceInspectWithRawFunc: func(ctx context.Context, serviceID string, options client.ServiceInspectOptions) (swarm.Service, []byte, error) {
return swarm.Service{}, []byte{}, fmt.Errorf("no such services: %s", serviceID)
},
expectedError: "no such services: service-id",
@@ -82,7 +83,7 @@ func TestRollbackWithErrors(t *testing.T) {
{
name: "service-update-failed",
args: []string{"service-id"},
serviceUpdateFunc: func(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options swarm.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error) {
serviceUpdateFunc: func(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, opts client.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error) {
return swarm.ServiceUpdateResponse{}, fmt.Errorf("no such services: %s", serviceID)
},
expectedError: "no such services: service-id",

View File

@@ -9,7 +9,6 @@ import (
"github.com/docker/cli/cli"
"github.com/docker/cli/cli/command"
"github.com/moby/moby/api/types/swarm"
"github.com/moby/moby/api/types/versions"
"github.com/moby/moby/client"
"github.com/spf13/cobra"
@@ -94,7 +93,7 @@ func runScale(ctx context.Context, dockerCLI command.Cli, options *scaleOptions,
}
func runServiceScale(ctx context.Context, apiClient client.ServiceAPIClient, serviceID string, scale uint64) (warnings []string, _ error) {
service, _, err := apiClient.ServiceInspectWithRaw(ctx, serviceID, swarm.ServiceInspectOptions{})
service, _, err := apiClient.ServiceInspectWithRaw(ctx, serviceID, client.ServiceInspectOptions{})
if err != nil {
return nil, err
}
@@ -109,7 +108,7 @@ func runServiceScale(ctx context.Context, apiClient client.ServiceAPIClient, ser
return nil, errors.New("scale can only be used with replicated or replicated-job mode")
}
response, err := apiClient.ServiceUpdate(ctx, service.ID, service.Version, service.Spec, swarm.ServiceUpdateOptions{})
response, err := apiClient.ServiceUpdate(ctx, service.ID, service.Version, service.Spec, client.ServiceUpdateOptions{})
if err != nil {
return nil, err
}

View File

@@ -14,7 +14,6 @@ import (
"github.com/docker/cli/opts/swarmopts"
"github.com/moby/moby/api/types/container"
"github.com/moby/moby/api/types/mount"
"github.com/moby/moby/api/types/network"
"github.com/moby/moby/api/types/swarm"
"github.com/moby/moby/api/types/versions"
"github.com/moby/moby/client"
@@ -155,7 +154,7 @@ func newListOptsVarWithValidator(validator opts.ValidatorFctType) *opts.ListOpts
func runUpdate(ctx context.Context, dockerCLI command.Cli, flags *pflag.FlagSet, options *serviceOptions, serviceID string) error {
apiClient := dockerCLI.Client()
service, _, err := apiClient.ServiceInspectWithRaw(ctx, serviceID, swarm.ServiceInspectOptions{})
service, _, err := apiClient.ServiceInspectWithRaw(ctx, serviceID, client.ServiceInspectOptions{})
if err != nil {
return err
}
@@ -200,7 +199,7 @@ func runUpdate(ctx context.Context, dockerCLI command.Cli, flags *pflag.FlagSet,
}
}
updateOpts := swarm.ServiceUpdateOptions{}
updateOpts := client.ServiceUpdateOptions{}
if serverSideRollback {
updateOpts.Rollback = "previous"
}
@@ -1328,7 +1327,7 @@ func updateNetworks(ctx context.Context, apiClient client.NetworkAPIClient, flag
toRemove := buildToRemoveSet(flags, flagNetworkRemove)
idsToRemove := make(map[string]struct{})
for networkIDOrName := range toRemove {
nw, err := apiClient.NetworkInspect(ctx, networkIDOrName, network.InspectOptions{Scope: "swarm"})
nw, err := apiClient.NetworkInspect(ctx, networkIDOrName, client.NetworkInspectOptions{Scope: "swarm"})
if err != nil {
return err
}

View File

@@ -12,6 +12,7 @@ import (
"github.com/moby/moby/api/types/mount"
"github.com/moby/moby/api/types/network"
"github.com/moby/moby/api/types/swarm"
"github.com/moby/moby/client"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
)
@@ -852,7 +853,7 @@ func TestUpdateNetworks(t *testing.T) {
}
apiClient := &fakeClient{
networkInspectFunc: func(ctx context.Context, networkID string, options network.InspectOptions) (network.Inspect, error) {
networkInspectFunc: func(ctx context.Context, networkID string, options client.NetworkInspectOptions) (network.Inspect, error) {
for _, nw := range nws {
if nw.ID == networkID || nw.Name == networkID {
return nw, nil
@@ -1202,7 +1203,7 @@ func TestUpdateGetUpdatedConfigs(t *testing.T) {
// fakeConfigAPIClientList is actually defined in create_test.go,
// but we'll use it here as well
var fakeClient fakeConfigAPIClientList = func(_ context.Context, opts swarm.ConfigListOptions) ([]swarm.Config, error) {
var fakeClient fakeConfigAPIClientList = func(_ context.Context, opts client.ConfigListOptions) ([]swarm.Config, error) {
names := opts.Filters.Get("name")
assert.Equal(t, len(names), len(tc.lookupConfigs))

View File

@@ -27,15 +27,15 @@ type fakeClient struct {
removedSecrets []string
removedConfigs []string
serviceListFunc func(options swarm.ServiceListOptions) ([]swarm.Service, error)
networkListFunc func(options network.ListOptions) ([]network.Summary, error)
serviceListFunc func(options client.ServiceListOptions) ([]swarm.Service, error)
networkListFunc func(options client.NetworkListOptions) ([]network.Summary, error)
secretListFunc func(options swarm.SecretListOptions) ([]swarm.Secret, error)
configListFunc func(options swarm.ConfigListOptions) ([]swarm.Config, error)
nodeListFunc func(options swarm.NodeListOptions) ([]swarm.Node, error)
taskListFunc func(options swarm.TaskListOptions) ([]swarm.Task, error)
configListFunc func(options client.ConfigListOptions) ([]swarm.Config, error)
nodeListFunc func(options client.NodeListOptions) ([]swarm.Node, error)
taskListFunc func(options client.TaskListOptions) ([]swarm.Task, error)
nodeInspectWithRaw func(ref string) (swarm.Node, []byte, error)
serviceUpdateFunc func(serviceID string, version swarm.Version, service swarm.ServiceSpec, options swarm.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error)
serviceUpdateFunc func(serviceID string, version swarm.Version, service swarm.ServiceSpec, options client.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error)
serviceRemoveFunc func(serviceID string) error
networkRemoveFunc func(networkID string) error
@@ -54,7 +54,7 @@ func (cli *fakeClient) ClientVersion() string {
return cli.version
}
func (cli *fakeClient) ServiceList(_ context.Context, options swarm.ServiceListOptions) ([]swarm.Service, error) {
func (cli *fakeClient) ServiceList(_ context.Context, options client.ServiceListOptions) ([]swarm.Service, error) {
if cli.serviceListFunc != nil {
return cli.serviceListFunc(options)
}
@@ -69,7 +69,7 @@ func (cli *fakeClient) ServiceList(_ context.Context, options swarm.ServiceListO
return servicesList, nil
}
func (cli *fakeClient) NetworkList(_ context.Context, options network.ListOptions) ([]network.Summary, error) {
func (cli *fakeClient) NetworkList(_ context.Context, options client.NetworkListOptions) ([]network.Summary, error) {
if cli.networkListFunc != nil {
return cli.networkListFunc(options)
}
@@ -99,7 +99,7 @@ func (cli *fakeClient) SecretList(_ context.Context, options swarm.SecretListOpt
return secretsList, nil
}
func (cli *fakeClient) ConfigList(_ context.Context, options swarm.ConfigListOptions) ([]swarm.Config, error) {
func (cli *fakeClient) ConfigList(_ context.Context, options client.ConfigListOptions) ([]swarm.Config, error) {
if cli.configListFunc != nil {
return cli.configListFunc(options)
}
@@ -114,14 +114,14 @@ func (cli *fakeClient) ConfigList(_ context.Context, options swarm.ConfigListOpt
return configsList, nil
}
func (cli *fakeClient) TaskList(_ context.Context, options swarm.TaskListOptions) ([]swarm.Task, error) {
func (cli *fakeClient) TaskList(_ context.Context, options client.TaskListOptions) ([]swarm.Task, error) {
if cli.taskListFunc != nil {
return cli.taskListFunc(options)
}
return []swarm.Task{}, nil
}
func (cli *fakeClient) NodeList(_ context.Context, options swarm.NodeListOptions) ([]swarm.Node, error) {
func (cli *fakeClient) NodeList(_ context.Context, options client.NodeListOptions) ([]swarm.Node, error) {
if cli.nodeListFunc != nil {
return cli.nodeListFunc(options)
}
@@ -135,7 +135,7 @@ func (cli *fakeClient) NodeInspectWithRaw(_ context.Context, ref string) (swarm.
return swarm.Node{}, nil, nil
}
func (cli *fakeClient) ServiceUpdate(_ context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options swarm.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error) {
func (cli *fakeClient) ServiceUpdate(_ context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options client.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error) {
if cli.serviceUpdateFunc != nil {
return cli.serviceUpdateFunc(serviceID, version, service, options)
}
@@ -179,7 +179,7 @@ func (cli *fakeClient) ConfigRemove(_ context.Context, configID string) error {
return nil
}
func (*fakeClient) ServiceInspectWithRaw(_ context.Context, serviceID string, _ swarm.ServiceInspectOptions) (swarm.Service, []byte, error) {
func (*fakeClient) ServiceInspectWithRaw(_ context.Context, serviceID string, _ client.ServiceInspectOptions) (swarm.Service, []byte, error) {
return swarm.Service{
ID: serviceID,
Spec: swarm.ServiceSpec{

View File

@@ -8,6 +8,7 @@ import (
"github.com/docker/cli/internal/test"
"github.com/docker/cli/internal/test/builders"
"github.com/moby/moby/api/types/swarm"
"github.com/moby/moby/client"
"gotest.tools/v3/assert"
"gotest.tools/v3/golden"
)
@@ -16,7 +17,7 @@ func TestListErrors(t *testing.T) {
testCases := []struct {
args []string
flags map[string]string
serviceListFunc func(options swarm.ServiceListOptions) ([]swarm.Service, error)
serviceListFunc func(options client.ServiceListOptions) ([]swarm.Service, error)
expectedError string
}{
{
@@ -32,14 +33,14 @@ func TestListErrors(t *testing.T) {
},
{
args: []string{},
serviceListFunc: func(options swarm.ServiceListOptions) ([]swarm.Service, error) {
serviceListFunc: func(options client.ServiceListOptions) ([]swarm.Service, error) {
return []swarm.Service{}, errors.New("error getting services")
},
expectedError: "error getting services",
},
{
args: []string{},
serviceListFunc: func(options swarm.ServiceListOptions) ([]swarm.Service, error) {
serviceListFunc: func(options client.ServiceListOptions) ([]swarm.Service, error) {
return []swarm.Service{*builders.Service()}, nil
},
expectedError: "cannot get label",
@@ -114,7 +115,7 @@ func TestStackList(t *testing.T) {
)
}
cli := test.NewFakeCli(&fakeClient{
serviceListFunc: func(options swarm.ServiceListOptions) ([]swarm.Service, error) {
serviceListFunc: func(options client.ServiceListOptions) ([]swarm.Service, error) {
return services, nil
},
})

View File

@@ -10,6 +10,7 @@ import (
"github.com/docker/cli/internal/test"
"github.com/docker/cli/internal/test/builders"
"github.com/moby/moby/api/types/swarm"
"github.com/moby/moby/client"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
"gotest.tools/v3/golden"
@@ -18,7 +19,7 @@ import (
func TestStackPsErrors(t *testing.T) {
testCases := []struct {
args []string
taskListFunc func(options swarm.TaskListOptions) ([]swarm.Task, error)
taskListFunc func(options client.TaskListOptions) ([]swarm.Task, error)
expectedError string
}{
{
@@ -31,7 +32,7 @@ func TestStackPsErrors(t *testing.T) {
},
{
args: []string{"foo"},
taskListFunc: func(options swarm.TaskListOptions) ([]swarm.Task, error) {
taskListFunc: func(options client.TaskListOptions) ([]swarm.Task, error) {
return nil, errors.New("error getting tasks")
},
expectedError: "error getting tasks",
@@ -54,7 +55,7 @@ func TestStackPsErrors(t *testing.T) {
func TestStackPs(t *testing.T) {
testCases := []struct {
doc string
taskListFunc func(swarm.TaskListOptions) ([]swarm.Task, error)
taskListFunc func(client.TaskListOptions) ([]swarm.Task, error)
nodeInspectWithRaw func(string) (swarm.Node, []byte, error)
config configfile.ConfigFile
args []string
@@ -69,7 +70,7 @@ func TestStackPs(t *testing.T) {
},
{
doc: "WithEmptyStack",
taskListFunc: func(options swarm.TaskListOptions) ([]swarm.Task, error) {
taskListFunc: func(options client.TaskListOptions) ([]swarm.Task, error) {
return []swarm.Task{}, nil
},
args: []string{"foo"},
@@ -77,7 +78,7 @@ func TestStackPs(t *testing.T) {
},
{
doc: "WithQuietOption",
taskListFunc: func(options swarm.TaskListOptions) ([]swarm.Task, error) {
taskListFunc: func(options client.TaskListOptions) ([]swarm.Task, error) {
return []swarm.Task{*builders.Task(builders.TaskID("id-foo"))}, nil
},
args: []string{"foo"},
@@ -88,7 +89,7 @@ func TestStackPs(t *testing.T) {
},
{
doc: "WithNoTruncOption",
taskListFunc: func(options swarm.TaskListOptions) ([]swarm.Task, error) {
taskListFunc: func(options client.TaskListOptions) ([]swarm.Task, error) {
return []swarm.Task{*builders.Task(builders.TaskID("xn4cypcov06f2w8gsbaf2lst3"))}, nil
},
args: []string{"foo"},
@@ -100,7 +101,7 @@ func TestStackPs(t *testing.T) {
},
{
doc: "WithNoResolveOption",
taskListFunc: func(options swarm.TaskListOptions) ([]swarm.Task, error) {
taskListFunc: func(options client.TaskListOptions) ([]swarm.Task, error) {
return []swarm.Task{*builders.Task(
builders.TaskNodeID("id-node-foo"),
)}, nil
@@ -117,7 +118,7 @@ func TestStackPs(t *testing.T) {
},
{
doc: "WithFormat",
taskListFunc: func(options swarm.TaskListOptions) ([]swarm.Task, error) {
taskListFunc: func(options client.TaskListOptions) ([]swarm.Task, error) {
return []swarm.Task{*builders.Task(builders.TaskServiceID("service-id-foo"))}, nil
},
args: []string{"foo"},
@@ -128,7 +129,7 @@ func TestStackPs(t *testing.T) {
},
{
doc: "WithConfigFormat",
taskListFunc: func(options swarm.TaskListOptions) ([]swarm.Task, error) {
taskListFunc: func(options client.TaskListOptions) ([]swarm.Task, error) {
return []swarm.Task{*builders.Task(builders.TaskServiceID("service-id-foo"))}, nil
},
config: configfile.ConfigFile{
@@ -139,7 +140,7 @@ func TestStackPs(t *testing.T) {
},
{
doc: "WithoutFormat",
taskListFunc: func(options swarm.TaskListOptions) ([]swarm.Task, error) {
taskListFunc: func(options client.TaskListOptions) ([]swarm.Task, error) {
return []swarm.Task{*builders.Task(
builders.TaskID("id-foo"),
builders.TaskServiceID("service-id-foo"),

View File

@@ -9,6 +9,7 @@ import (
"github.com/docker/cli/internal/test"
"github.com/docker/cli/internal/test/builders"
"github.com/moby/moby/api/types/swarm"
"github.com/moby/moby/client"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
"gotest.tools/v3/golden"
@@ -18,37 +19,37 @@ func TestStackServicesErrors(t *testing.T) {
testCases := []struct {
args []string
flags map[string]string
serviceListFunc func(options swarm.ServiceListOptions) ([]swarm.Service, error)
nodeListFunc func(options swarm.NodeListOptions) ([]swarm.Node, error)
taskListFunc func(options swarm.TaskListOptions) ([]swarm.Task, error)
serviceListFunc func(options client.ServiceListOptions) ([]swarm.Service, error)
nodeListFunc func(options client.NodeListOptions) ([]swarm.Node, error)
taskListFunc func(options client.TaskListOptions) ([]swarm.Task, error)
expectedError string
}{
{
args: []string{"foo"},
serviceListFunc: func(options swarm.ServiceListOptions) ([]swarm.Service, error) {
serviceListFunc: func(options client.ServiceListOptions) ([]swarm.Service, error) {
return nil, errors.New("error getting services")
},
expectedError: "error getting services",
},
{
args: []string{"foo"},
serviceListFunc: func(options swarm.ServiceListOptions) ([]swarm.Service, error) {
serviceListFunc: func(options client.ServiceListOptions) ([]swarm.Service, error) {
return []swarm.Service{*builders.Service(builders.GlobalService())}, nil
},
nodeListFunc: func(options swarm.NodeListOptions) ([]swarm.Node, error) {
nodeListFunc: func(options client.NodeListOptions) ([]swarm.Node, error) {
return nil, errors.New("error getting nodes")
},
taskListFunc: func(options swarm.TaskListOptions) ([]swarm.Task, error) {
taskListFunc: func(options client.TaskListOptions) ([]swarm.Task, error) {
return []swarm.Task{*builders.Task()}, nil
},
expectedError: "error getting nodes",
},
{
args: []string{"foo"},
serviceListFunc: func(options swarm.ServiceListOptions) ([]swarm.Service, error) {
serviceListFunc: func(options client.ServiceListOptions) ([]swarm.Service, error) {
return []swarm.Service{*builders.Service(builders.GlobalService())}, nil
},
taskListFunc: func(options swarm.TaskListOptions) ([]swarm.Task, error) {
taskListFunc: func(options client.TaskListOptions) ([]swarm.Task, error) {
return nil, errors.New("error getting tasks")
},
expectedError: "error getting tasks",
@@ -58,7 +59,7 @@ func TestStackServicesErrors(t *testing.T) {
flags: map[string]string{
"format": "{{invalid format}}",
},
serviceListFunc: func(options swarm.ServiceListOptions) ([]swarm.Service, error) {
serviceListFunc: func(options client.ServiceListOptions) ([]swarm.Service, error) {
return []swarm.Service{*builders.Service()}, nil
},
expectedError: "template parsing error",
@@ -95,7 +96,7 @@ func TestRunServicesWithEmptyName(t *testing.T) {
func TestStackServicesEmptyServiceList(t *testing.T) {
fakeCli := test.NewFakeCli(&fakeClient{
serviceListFunc: func(options swarm.ServiceListOptions) ([]swarm.Service, error) {
serviceListFunc: func(options client.ServiceListOptions) ([]swarm.Service, error) {
return []swarm.Service{}, nil
},
})
@@ -108,7 +109,7 @@ func TestStackServicesEmptyServiceList(t *testing.T) {
func TestStackServicesWithQuietOption(t *testing.T) {
cli := test.NewFakeCli(&fakeClient{
serviceListFunc: func(options swarm.ServiceListOptions) ([]swarm.Service, error) {
serviceListFunc: func(options client.ServiceListOptions) ([]swarm.Service, error) {
return []swarm.Service{*builders.Service(builders.ServiceID("id-foo"))}, nil
},
})
@@ -121,7 +122,7 @@ func TestStackServicesWithQuietOption(t *testing.T) {
func TestStackServicesWithFormat(t *testing.T) {
cli := test.NewFakeCli(&fakeClient{
serviceListFunc: func(options swarm.ServiceListOptions) ([]swarm.Service, error) {
serviceListFunc: func(options client.ServiceListOptions) ([]swarm.Service, error) {
return []swarm.Service{
*builders.Service(builders.ServiceName("service-name-foo")),
}, nil
@@ -136,7 +137,7 @@ func TestStackServicesWithFormat(t *testing.T) {
func TestStackServicesWithConfigFormat(t *testing.T) {
cli := test.NewFakeCli(&fakeClient{
serviceListFunc: func(options swarm.ServiceListOptions) ([]swarm.Service, error) {
serviceListFunc: func(options client.ServiceListOptions) ([]swarm.Service, error) {
return []swarm.Service{
*builders.Service(builders.ServiceName("service-name-foo")),
}, nil
@@ -153,7 +154,7 @@ func TestStackServicesWithConfigFormat(t *testing.T) {
func TestStackServicesWithoutFormat(t *testing.T) {
cli := test.NewFakeCli(&fakeClient{
serviceListFunc: func(options swarm.ServiceListOptions) ([]swarm.Service, error) {
serviceListFunc: func(options client.ServiceListOptions) ([]swarm.Service, error) {
return []swarm.Service{*builders.Service(
builders.ServiceName("name-foo"),
builders.ServiceID("id-foo"),

View File

@@ -27,15 +27,15 @@ type fakeClient struct {
removedSecrets []string
removedConfigs []string
serviceListFunc func(options swarm.ServiceListOptions) ([]swarm.Service, error)
networkListFunc func(options network.ListOptions) ([]network.Summary, error)
serviceListFunc func(options client.ServiceListOptions) ([]swarm.Service, error)
networkListFunc func(options client.NetworkListOptions) ([]network.Summary, error)
secretListFunc func(options swarm.SecretListOptions) ([]swarm.Secret, error)
configListFunc func(options swarm.ConfigListOptions) ([]swarm.Config, error)
nodeListFunc func(options swarm.NodeListOptions) ([]swarm.Node, error)
taskListFunc func(options swarm.TaskListOptions) ([]swarm.Task, error)
configListFunc func(options client.ConfigListOptions) ([]swarm.Config, error)
nodeListFunc func(options client.NodeListOptions) ([]swarm.Node, error)
taskListFunc func(options client.TaskListOptions) ([]swarm.Task, error)
nodeInspectWithRaw func(ref string) (swarm.Node, []byte, error)
serviceUpdateFunc func(serviceID string, version swarm.Version, service swarm.ServiceSpec, options swarm.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error)
serviceUpdateFunc func(serviceID string, version swarm.Version, service swarm.ServiceSpec, options client.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error)
serviceRemoveFunc func(serviceID string) error
networkRemoveFunc func(networkID string) error
@@ -54,7 +54,7 @@ func (cli *fakeClient) ClientVersion() string {
return cli.version
}
func (cli *fakeClient) ServiceList(_ context.Context, options swarm.ServiceListOptions) ([]swarm.Service, error) {
func (cli *fakeClient) ServiceList(_ context.Context, options client.ServiceListOptions) ([]swarm.Service, error) {
if cli.serviceListFunc != nil {
return cli.serviceListFunc(options)
}
@@ -69,7 +69,7 @@ func (cli *fakeClient) ServiceList(_ context.Context, options swarm.ServiceListO
return servicesList, nil
}
func (cli *fakeClient) NetworkList(_ context.Context, options network.ListOptions) ([]network.Summary, error) {
func (cli *fakeClient) NetworkList(_ context.Context, options client.NetworkListOptions) ([]network.Summary, error) {
if cli.networkListFunc != nil {
return cli.networkListFunc(options)
}
@@ -99,7 +99,7 @@ func (cli *fakeClient) SecretList(_ context.Context, options swarm.SecretListOpt
return secretsList, nil
}
func (cli *fakeClient) ConfigList(_ context.Context, options swarm.ConfigListOptions) ([]swarm.Config, error) {
func (cli *fakeClient) ConfigList(_ context.Context, options client.ConfigListOptions) ([]swarm.Config, error) {
if cli.configListFunc != nil {
return cli.configListFunc(options)
}
@@ -114,14 +114,14 @@ func (cli *fakeClient) ConfigList(_ context.Context, options swarm.ConfigListOpt
return configsList, nil
}
func (cli *fakeClient) TaskList(_ context.Context, options swarm.TaskListOptions) ([]swarm.Task, error) {
func (cli *fakeClient) TaskList(_ context.Context, options client.TaskListOptions) ([]swarm.Task, error) {
if cli.taskListFunc != nil {
return cli.taskListFunc(options)
}
return []swarm.Task{}, nil
}
func (cli *fakeClient) NodeList(_ context.Context, options swarm.NodeListOptions) ([]swarm.Node, error) {
func (cli *fakeClient) NodeList(_ context.Context, options client.NodeListOptions) ([]swarm.Node, error) {
if cli.nodeListFunc != nil {
return cli.nodeListFunc(options)
}
@@ -135,7 +135,7 @@ func (cli *fakeClient) NodeInspectWithRaw(_ context.Context, ref string) (swarm.
return swarm.Node{}, nil, nil
}
func (cli *fakeClient) ServiceUpdate(_ context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options swarm.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error) {
func (cli *fakeClient) ServiceUpdate(_ context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options client.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error) {
if cli.serviceUpdateFunc != nil {
return cli.serviceUpdateFunc(serviceID, version, service, options)
}

View File

@@ -30,11 +30,11 @@ func getAllStacksFilter() filters.Args {
}
func getStackServices(ctx context.Context, apiclient client.APIClient, namespace string) ([]swarm.Service, error) {
return apiclient.ServiceList(ctx, swarm.ServiceListOptions{Filters: getStackFilter(namespace)})
return apiclient.ServiceList(ctx, client.ServiceListOptions{Filters: getStackFilter(namespace)})
}
func getStackNetworks(ctx context.Context, apiclient client.APIClient, namespace string) ([]network.Summary, error) {
return apiclient.NetworkList(ctx, network.ListOptions{Filters: getStackFilter(namespace)})
return apiclient.NetworkList(ctx, client.NetworkListOptions{Filters: getStackFilter(namespace)})
}
func getStackSecrets(ctx context.Context, apiclient client.APIClient, namespace string) ([]swarm.Secret, error) {
@@ -42,9 +42,9 @@ func getStackSecrets(ctx context.Context, apiclient client.APIClient, namespace
}
func getStackConfigs(ctx context.Context, apiclient client.APIClient, namespace string) ([]swarm.Config, error) {
return apiclient.ConfigList(ctx, swarm.ConfigListOptions{Filters: getStackFilter(namespace)})
return apiclient.ConfigList(ctx, client.ConfigListOptions{Filters: getStackFilter(namespace)})
}
func getStackTasks(ctx context.Context, apiclient client.APIClient, namespace string) ([]swarm.Task, error) {
return apiclient.TaskList(ctx, swarm.TaskListOptions{Filters: getStackFilter(namespace)})
return apiclient.TaskList(ctx, client.TaskListOptions{Filters: getStackFilter(namespace)})
}

View File

@@ -95,7 +95,7 @@ func validateExternalNetworks(ctx context.Context, apiClient client.NetworkAPICl
// local-scoped networks, so there's no need to inspect them.
continue
}
nw, err := apiClient.NetworkInspect(ctx, networkName, network.InspectOptions{})
nw, err := apiClient.NetworkInspect(ctx, networkName, client.NetworkInspectOptions{})
switch {
case errdefs.IsNotFound(err):
return fmt.Errorf("network %q is declared as external, but could not be found. You need to create a swarm-scoped network before the stack is deployed", networkName)
@@ -220,7 +220,7 @@ func deployServices(ctx context.Context, dockerCLI command.Cli, services map[str
if service, exists := existingServiceMap[name]; exists {
_, _ = fmt.Fprintf(out, "Updating service %s (id: %s)\n", name, service.ID)
updateOpts := swarm.ServiceUpdateOptions{EncodedRegistryAuth: encodedAuth}
updateOpts := client.ServiceUpdateOptions{EncodedRegistryAuth: encodedAuth}
switch resolveImage {
case ResolveImageAlways:
@@ -265,7 +265,7 @@ func deployServices(ctx context.Context, dockerCLI command.Cli, services map[str
} else {
_, _ = fmt.Fprintln(out, "Creating service", name)
createOpts := swarm.ServiceCreateOptions{EncodedRegistryAuth: encodedAuth}
createOpts := client.ServiceCreateOptions{EncodedRegistryAuth: encodedAuth}
// query registry if flag disabling it was not set
if resolveImage == ResolveImageAlways || resolveImage == ResolveImageChanged {

View File

@@ -7,6 +7,7 @@ import (
"github.com/docker/cli/internal/test/network"
networktypes "github.com/moby/moby/api/types/network"
"github.com/moby/moby/client"
"gotest.tools/v3/assert"
)
@@ -49,13 +50,13 @@ func TestValidateExternalNetworks(t *testing.T) {
}
for _, testcase := range testcases {
client := &network.FakeClient{
NetworkInspectFunc: func(_ context.Context, _ string, _ networktypes.InspectOptions) (networktypes.Inspect, error) {
fakeAPIClient := &network.FakeClient{
NetworkInspectFunc: func(_ context.Context, _ string, _ client.NetworkInspectOptions) (networktypes.Inspect, error) {
return testcase.inspectResponse, testcase.inspectError
},
}
networks := []string{testcase.network}
err := validateExternalNetworks(context.Background(), client, networks)
err := validateExternalNetworks(context.Background(), fakeAPIClient, networks)
if testcase.expectedMsg == "" {
assert.NilError(t, err)
} else {

View File

@@ -7,6 +7,7 @@ import (
"github.com/docker/cli/cli/compose/convert"
"github.com/docker/cli/internal/test"
"github.com/moby/moby/api/types/swarm"
"github.com/moby/moby/client"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
)
@@ -32,12 +33,12 @@ func TestServiceUpdateResolveImageChanged(t *testing.T) {
namespace := convert.NewNamespace("mystack")
var (
receivedOptions swarm.ServiceUpdateOptions
receivedOptions client.ServiceUpdateOptions
receivedService swarm.ServiceSpec
)
client := test.NewFakeCli(&fakeClient{
serviceListFunc: func(options swarm.ServiceListOptions) ([]swarm.Service, error) {
fakeCli := test.NewFakeCli(&fakeClient{
serviceListFunc: func(options client.ServiceListOptions) ([]swarm.Service, error) {
return []swarm.Service{
{
Spec: swarm.ServiceSpec{
@@ -55,7 +56,7 @@ func TestServiceUpdateResolveImageChanged(t *testing.T) {
},
}, nil
},
serviceUpdateFunc: func(serviceID string, version swarm.Version, service swarm.ServiceSpec, options swarm.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error) {
serviceUpdateFunc: func(serviceID string, version swarm.Version, service swarm.ServiceSpec, options client.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error) {
receivedOptions = options
receivedService = service
return swarm.ServiceUpdateResponse{}, nil
@@ -97,14 +98,14 @@ func TestServiceUpdateResolveImageChanged(t *testing.T) {
},
},
}
_, err := deployServices(ctx, client, spec, namespace, false, ResolveImageChanged)
_, err := deployServices(ctx, fakeCli, spec, namespace, false, ResolveImageChanged)
assert.NilError(t, err)
assert.Check(t, is.Equal(receivedOptions.QueryRegistry, tc.expectedQueryRegistry))
assert.Check(t, is.Equal(receivedService.TaskTemplate.ContainerSpec.Image, tc.expectedImage))
assert.Check(t, is.Equal(receivedService.TaskTemplate.ForceUpdate, tc.expectedForceUpdate))
receivedService = swarm.ServiceSpec{}
receivedOptions = swarm.ServiceUpdateOptions{}
receivedOptions = client.ServiceUpdateOptions{}
})
}
}

View File

@@ -5,7 +5,6 @@ import (
"github.com/docker/cli/cli/command/stack/formatter"
"github.com/docker/cli/cli/compose/convert"
"github.com/moby/moby/api/types/swarm"
"github.com/moby/moby/client"
"github.com/pkg/errors"
)
@@ -14,7 +13,7 @@ import (
func GetStacks(ctx context.Context, apiClient client.ServiceAPIClient) ([]*formatter.Stack, error) {
services, err := apiClient.ServiceList(
ctx,
swarm.ServiceListOptions{Filters: getAllStacksFilter()})
client.ServiceListOptions{Filters: getAllStacksFilter()})
if err != nil {
return nil, err
}

View File

@@ -8,7 +8,7 @@ import (
"github.com/docker/cli/cli/command/idresolver"
"github.com/docker/cli/cli/command/stack/options"
"github.com/docker/cli/cli/command/task"
"github.com/moby/moby/api/types/swarm"
"github.com/moby/moby/client"
)
// RunPS is the swarm implementation of docker stack ps
@@ -16,7 +16,7 @@ func RunPS(ctx context.Context, dockerCLI command.Cli, opts options.PS) error {
filter := getStackFilterFromOpt(opts.Namespace, opts.Filter)
apiClient := dockerCLI.Client()
tasks, err := apiClient.TaskList(ctx, swarm.TaskListOptions{Filters: filter})
tasks, err := apiClient.TaskList(ctx, client.TaskListOptions{Filters: filter})
if err != nil {
return err
}

View File

@@ -7,16 +7,17 @@ import (
"github.com/docker/cli/cli/command/service"
"github.com/docker/cli/cli/command/stack/options"
"github.com/moby/moby/api/types/swarm"
"github.com/moby/moby/client"
)
// GetServices is the swarm implementation of listing stack services
func GetServices(ctx context.Context, dockerCli command.Cli, opts options.Services) ([]swarm.Service, error) {
func GetServices(ctx context.Context, dockerCLI command.Cli, opts options.Services) ([]swarm.Service, error) {
var (
err error
client = dockerCli.Client()
err error
apiClient = dockerCLI.Client()
)
listOpts := swarm.ServiceListOptions{
listOpts := client.ServiceListOptions{
Filters: getStackFilterFromOpt(opts.Namespace, opts.Filter),
// When not running "quiet", also get service status (number of running
// and desired tasks). Note that this is only supported on API v1.41 and
@@ -25,7 +26,7 @@ func GetServices(ctx context.Context, dockerCli command.Cli, opts options.Servic
Status: !opts.Quiet,
}
services, err := client.ServiceList(ctx, listOpts)
services, err := apiClient.ServiceList(ctx, listOpts)
if err != nil {
return nil, err
}
@@ -43,7 +44,7 @@ func GetServices(ctx context.Context, dockerCli command.Cli, opts options.Servic
// situations where the client uses the "default" version. To account for
// these situations, we do a quick check for services that do not have
// a ServiceStatus set, and perform a lookup for those.
services, err = service.AppendServiceStatus(ctx, client, services)
services, err = service.AppendServiceStatus(ctx, apiClient, services)
if err != nil {
return nil, err
}

View File

@@ -12,6 +12,7 @@ import (
"github.com/docker/cli/cli/command/swarm/progress"
"github.com/docker/cli/internal/jsonstream"
"github.com/moby/moby/api/types/swarm"
"github.com/moby/moby/client"
"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
@@ -83,7 +84,7 @@ func runCA(ctx context.Context, dockerCLI command.Cli, flags *pflag.FlagSet, opt
}
updateSwarmSpec(&swarmInspect.Spec, flags, opts)
if err := apiClient.SwarmUpdate(ctx, swarmInspect.Version, swarmInspect.Spec, swarm.UpdateFlags{}); err != nil {
if err := apiClient.SwarmUpdate(ctx, swarmInspect.Version, swarmInspect.Spec, client.SwarmUpdateFlags{}); err != nil {
return err
}

View File

@@ -9,6 +9,7 @@ import (
"github.com/docker/cli/internal/test"
"github.com/moby/moby/api/types/swarm"
"github.com/moby/moby/client"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
)
@@ -167,7 +168,7 @@ type swarmUpdateRecorder struct {
spec swarm.Spec
}
func (s *swarmUpdateRecorder) swarmUpdate(sp swarm.Spec, _ swarm.UpdateFlags) error {
func (s *swarmUpdateRecorder) swarmUpdate(sp swarm.Spec, _ client.SwarmUpdateFlags) error {
s.spec = sp
return nil
}

View File

@@ -17,7 +17,7 @@ type fakeClient struct {
swarmGetUnlockKeyFunc func() (swarm.UnlockKeyResponse, error)
swarmJoinFunc func() error
swarmLeaveFunc func() error
swarmUpdateFunc func(swarm swarm.Spec, flags swarm.UpdateFlags) error
swarmUpdateFunc func(swarm swarm.Spec, flags client.SwarmUpdateFlags) error
swarmUnlockFunc func(req swarm.UnlockRequest) error
}
@@ -70,7 +70,7 @@ func (cli *fakeClient) SwarmLeave(context.Context, bool) error {
return nil
}
func (cli *fakeClient) SwarmUpdate(_ context.Context, _ swarm.Version, swarmSpec swarm.Spec, flags swarm.UpdateFlags) error {
func (cli *fakeClient) SwarmUpdate(_ context.Context, _ swarm.Version, swarmSpec swarm.Spec, flags client.SwarmUpdateFlags) error {
if cli.swarmUpdateFunc != nil {
return cli.swarmUpdateFunc(swarmSpec, flags)
}

View File

@@ -6,7 +6,7 @@ import (
"github.com/docker/cli/cli"
"github.com/docker/cli/cli/command"
"github.com/moby/moby/api/types/swarm"
"github.com/moby/moby/client"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)
@@ -57,7 +57,7 @@ func runJoinToken(ctx context.Context, dockerCLI command.Cli, opts joinTokenOpti
return err
}
err = apiClient.SwarmUpdate(ctx, sw.Version, sw.Spec, swarm.UpdateFlags{
err = apiClient.SwarmUpdate(ctx, sw.Version, sw.Spec, client.SwarmUpdateFlags{
RotateWorkerToken: worker,
RotateManagerToken: manager,
})

View File

@@ -10,6 +10,7 @@ import (
"github.com/docker/cli/internal/test/builders"
"github.com/moby/moby/api/types/swarm"
"github.com/moby/moby/api/types/system"
"github.com/moby/moby/client"
"gotest.tools/v3/assert"
"gotest.tools/v3/golden"
)
@@ -21,7 +22,7 @@ func TestSwarmJoinTokenErrors(t *testing.T) {
flags map[string]string
infoFunc func() (system.Info, error)
swarmInspectFunc func() (swarm.Swarm, error)
swarmUpdateFunc func(swarm swarm.Spec, flags swarm.UpdateFlags) error
swarmUpdateFunc func(swarm swarm.Spec, flags client.SwarmUpdateFlags) error
nodeInspectFunc func() (swarm.Node, []byte, error)
expectedError string
}{
@@ -65,7 +66,7 @@ func TestSwarmJoinTokenErrors(t *testing.T) {
flags: map[string]string{
flagRotate: "true",
},
swarmUpdateFunc: func(swarm swarm.Spec, flags swarm.UpdateFlags) error {
swarmUpdateFunc: func(swarm swarm.Spec, flags client.SwarmUpdateFlags) error {
return errors.New("error updating the swarm")
},
expectedError: "error updating the swarm",

View File

@@ -25,7 +25,7 @@ const (
)
// RootRotationProgress outputs progress information for convergence of a root rotation.
func RootRotationProgress(ctx context.Context, dclient client.APIClient, progressWriter io.WriteCloser) error {
func RootRotationProgress(ctx context.Context, apiClient client.APIClient, progressWriter io.WriteCloser) error {
defer progressWriter.Close()
progressOut := streamformatter.NewJSONProgressOutput(progressWriter, false)
@@ -42,7 +42,7 @@ func RootRotationProgress(ctx context.Context, dclient client.APIClient, progres
var done bool
for {
info, err := dclient.SwarmInspect(ctx)
info, err := apiClient.SwarmInspect(ctx)
if err != nil {
return err
}
@@ -51,7 +51,7 @@ func RootRotationProgress(ctx context.Context, dclient client.APIClient, progres
return nil
}
nodes, err := dclient.NodeList(ctx, swarm.NodeListOptions{})
nodes, err := apiClient.NodeList(ctx, client.NodeListOptions{})
if err != nil {
return err
}

View File

@@ -8,7 +8,7 @@ import (
"github.com/docker/cli/cli"
"github.com/docker/cli/cli/command"
"github.com/docker/cli/cli/command/completion"
"github.com/moby/moby/api/types/swarm"
"github.com/moby/moby/client"
"github.com/pkg/errors"
"github.com/spf13/cobra"
)
@@ -46,7 +46,7 @@ func runUnlockKey(ctx context.Context, dockerCLI command.Cli, opts unlockKeyOpti
apiClient := dockerCLI.Client()
if opts.rotate {
flags := swarm.UpdateFlags{RotateManagerUnlockKey: true}
flags := client.SwarmUpdateFlags{RotateManagerUnlockKey: true}
sw, err := apiClient.SwarmInspect(ctx)
if err != nil {

View File

@@ -9,6 +9,7 @@ import (
"github.com/docker/cli/internal/test"
"github.com/docker/cli/internal/test/builders"
"github.com/moby/moby/api/types/swarm"
"github.com/moby/moby/client"
"gotest.tools/v3/assert"
"gotest.tools/v3/golden"
)
@@ -19,7 +20,7 @@ func TestSwarmUnlockKeyErrors(t *testing.T) {
args []string
flags map[string]string
swarmInspectFunc func() (swarm.Swarm, error)
swarmUpdateFunc func(swarm swarm.Spec, flags swarm.UpdateFlags) error
swarmUpdateFunc func(swarm swarm.Spec, flags client.SwarmUpdateFlags) error
swarmGetUnlockKeyFunc func() (swarm.UnlockKeyResponse, error)
expectedError string
}{
@@ -56,7 +57,7 @@ func TestSwarmUnlockKeyErrors(t *testing.T) {
swarmInspectFunc: func() (swarm.Swarm, error) {
return *builders.Swarm(builders.Autolock()), nil
},
swarmUpdateFunc: func(swarm swarm.Spec, flags swarm.UpdateFlags) error {
swarmUpdateFunc: func(swarm swarm.Spec, flags client.SwarmUpdateFlags) error {
return errors.New("error updating the swarm")
},
expectedError: "error updating the swarm",
@@ -104,7 +105,7 @@ func TestSwarmUnlockKey(t *testing.T) {
name string
flags map[string]string
swarmInspectFunc func() (swarm.Swarm, error)
swarmUpdateFunc func(swarm swarm.Spec, flags swarm.UpdateFlags) error
swarmUpdateFunc func(swarm swarm.Spec, flags client.SwarmUpdateFlags) error
swarmGetUnlockKeyFunc func() (swarm.UnlockKeyResponse, error)
}{
{

View File

@@ -7,7 +7,7 @@ import (
"github.com/docker/cli/cli"
"github.com/docker/cli/cli/command"
"github.com/docker/cli/cli/command/completion"
"github.com/moby/moby/api/types/swarm"
"github.com/moby/moby/client"
"github.com/pkg/errors"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
@@ -44,8 +44,6 @@ func newUpdateCommand(dockerCli command.Cli) *cobra.Command {
func runUpdate(ctx context.Context, dockerCLI command.Cli, flags *pflag.FlagSet, opts swarmOptions) error {
apiClient := dockerCLI.Client()
var updateFlags swarm.UpdateFlags
swarmInspect, err := apiClient.SwarmInspect(ctx)
if err != nil {
return err
@@ -57,7 +55,7 @@ func runUpdate(ctx context.Context, dockerCLI command.Cli, flags *pflag.FlagSet,
curAutoLock := swarmInspect.Spec.EncryptionConfig.AutoLockManagers
err = apiClient.SwarmUpdate(ctx, swarmInspect.Version, swarmInspect.Spec, updateFlags)
err = apiClient.SwarmUpdate(ctx, swarmInspect.Version, swarmInspect.Spec, client.SwarmUpdateFlags{})
if err != nil {
return err
}

View File

@@ -10,6 +10,7 @@ import (
"github.com/docker/cli/internal/test"
"github.com/docker/cli/internal/test/builders"
"github.com/moby/moby/api/types/swarm"
"github.com/moby/moby/client"
"gotest.tools/v3/assert"
"gotest.tools/v3/golden"
)
@@ -20,7 +21,7 @@ func TestSwarmUpdateErrors(t *testing.T) {
args []string
flags map[string]string
swarmInspectFunc func() (swarm.Swarm, error)
swarmUpdateFunc func(swarm swarm.Spec, flags swarm.UpdateFlags) error
swarmUpdateFunc func(swarm swarm.Spec, flags client.SwarmUpdateFlags) error
swarmGetUnlockKeyFunc func() (swarm.UnlockKeyResponse, error)
expectedError string
}{
@@ -44,7 +45,7 @@ func TestSwarmUpdateErrors(t *testing.T) {
flags: map[string]string{
flagTaskHistoryLimit: "10",
},
swarmUpdateFunc: func(swarm swarm.Spec, flags swarm.UpdateFlags) error {
swarmUpdateFunc: func(swarm swarm.Spec, flags client.SwarmUpdateFlags) error {
return errors.New("error updating the swarm")
},
expectedError: "error updating the swarm",
@@ -95,7 +96,7 @@ func TestSwarmUpdate(t *testing.T) {
args []string
flags map[string]string
swarmInspectFunc func() (swarm.Swarm, error)
swarmUpdateFunc func(swarm swarm.Spec, flags swarm.UpdateFlags) error
swarmUpdateFunc func(swarm swarm.Spec, flags client.SwarmUpdateFlags) error
swarmGetUnlockKeyFunc func() (swarm.UnlockKeyResponse, error)
}{
{
@@ -115,7 +116,7 @@ func TestSwarmUpdate(t *testing.T) {
swarmInspectFunc: func() (swarm.Swarm, error) {
return *swarmInfo, nil
},
swarmUpdateFunc: func(swarm swarm.Spec, flags swarm.UpdateFlags) error {
swarmUpdateFunc: func(swarm swarm.Spec, flags client.SwarmUpdateFlags) error {
if *swarm.Orchestration.TaskHistoryRetentionLimit != 10 {
return errors.New("historyLimit not correctly set")
}
@@ -154,7 +155,7 @@ func TestSwarmUpdate(t *testing.T) {
flagTaskHistoryLimit: "10",
flagAutolock: "true",
},
swarmUpdateFunc: func(swarm swarm.Spec, flags swarm.UpdateFlags) error {
swarmUpdateFunc: func(swarm swarm.Spec, flags client.SwarmUpdateFlags) error {
if *swarm.Orchestration.TaskHistoryRetentionLimit != 10 {
return errors.New("historyLimit not correctly set")
}

View File

@@ -21,14 +21,14 @@ type fakeClient struct {
version string
containerListFunc func(context.Context, container.ListOptions) ([]container.Summary, error)
containerPruneFunc func(ctx context.Context, pruneFilters filters.Args) (container.PruneReport, error)
eventsFn func(context.Context, events.ListOptions) (<-chan events.Message, <-chan error)
eventsFn func(context.Context, client.EventsListOptions) (<-chan events.Message, <-chan error)
imageListFunc func(ctx context.Context, options image.ListOptions) ([]image.Summary, error)
infoFunc func(ctx context.Context) (system.Info, error)
networkListFunc func(ctx context.Context, options network.ListOptions) ([]network.Summary, error)
networkListFunc func(ctx context.Context, options client.NetworkListOptions) ([]network.Summary, error)
networkPruneFunc func(ctx context.Context, pruneFilter filters.Args) (network.PruneReport, error)
nodeListFunc func(ctx context.Context, options swarm.NodeListOptions) ([]swarm.Node, error)
nodeListFunc func(ctx context.Context, options client.NodeListOptions) ([]swarm.Node, error)
serverVersion func(ctx context.Context) (types.Version, error)
volumeListFunc func(ctx context.Context, options volume.ListOptions) (volume.ListResponse, error)
volumeListFunc func(ctx context.Context, options client.VolumeListOptions) (volume.ListResponse, error)
}
func (cli *fakeClient) ClientVersion() string {
@@ -49,7 +49,7 @@ func (cli *fakeClient) ContainersPrune(ctx context.Context, pruneFilters filters
return container.PruneReport{}, nil
}
func (cli *fakeClient) Events(ctx context.Context, opts events.ListOptions) (<-chan events.Message, <-chan error) {
func (cli *fakeClient) Events(ctx context.Context, opts client.EventsListOptions) (<-chan events.Message, <-chan error) {
return cli.eventsFn(ctx, opts)
}
@@ -67,7 +67,7 @@ func (cli *fakeClient) Info(ctx context.Context) (system.Info, error) {
return system.Info{}, nil
}
func (cli *fakeClient) NetworkList(ctx context.Context, options network.ListOptions) ([]network.Summary, error) {
func (cli *fakeClient) NetworkList(ctx context.Context, options client.NetworkListOptions) ([]network.Summary, error) {
if cli.networkListFunc != nil {
return cli.networkListFunc(ctx, options)
}
@@ -81,7 +81,7 @@ func (cli *fakeClient) NetworksPrune(ctx context.Context, pruneFilter filters.Ar
return network.PruneReport{}, nil
}
func (cli *fakeClient) NodeList(ctx context.Context, options swarm.NodeListOptions) ([]swarm.Node, error) {
func (cli *fakeClient) NodeList(ctx context.Context, options client.NodeListOptions) ([]swarm.Node, error) {
if cli.nodeListFunc != nil {
return cli.nodeListFunc(ctx, options)
}
@@ -92,7 +92,7 @@ func (cli *fakeClient) ServerVersion(ctx context.Context) (types.Version, error)
return cli.serverVersion(ctx)
}
func (cli *fakeClient) VolumeList(ctx context.Context, options volume.ListOptions) (volume.ListResponse, error) {
func (cli *fakeClient) VolumeList(ctx context.Context, options client.VolumeListOptions) (volume.ListResponse, error) {
if cli.volumeListFunc != nil {
return cli.volumeListFunc(ctx, options)
}

View File

@@ -6,9 +6,7 @@ import (
"github.com/docker/cli/cli/command/completion"
"github.com/moby/moby/api/types/events"
"github.com/moby/moby/api/types/image"
"github.com/moby/moby/api/types/network"
"github.com/moby/moby/api/types/swarm"
"github.com/moby/moby/api/types/volume"
"github.com/moby/moby/client"
"github.com/spf13/cobra"
)
@@ -197,7 +195,7 @@ func imageNames(dockerCLI completion.APIClientProvider, cmd *cobra.Command) []st
// networkNames contacts the API to get a list of network names.
// In case of an error, an empty list is returned.
func networkNames(dockerCLI completion.APIClientProvider, cmd *cobra.Command) []string {
list, err := dockerCLI.Client().NetworkList(cmd.Context(), network.ListOptions{})
list, err := dockerCLI.Client().NetworkList(cmd.Context(), client.NetworkListOptions{})
if err != nil {
return []string{}
}
@@ -211,7 +209,7 @@ func networkNames(dockerCLI completion.APIClientProvider, cmd *cobra.Command) []
// nodeNames contacts the API to get a list of node names.
// In case of an error, an empty list is returned.
func nodeNames(dockerCLI completion.APIClientProvider, cmd *cobra.Command) []string {
list, err := dockerCLI.Client().NodeList(cmd.Context(), swarm.NodeListOptions{})
list, err := dockerCLI.Client().NodeList(cmd.Context(), client.NodeListOptions{})
if err != nil {
return []string{}
}
@@ -225,7 +223,7 @@ func nodeNames(dockerCLI completion.APIClientProvider, cmd *cobra.Command) []str
// volumeNames contacts the API to get a list of volume names.
// In case of an error, an empty list is returned.
func volumeNames(dockerCLI completion.APIClientProvider, cmd *cobra.Command) []string {
list, err := dockerCLI.Client().VolumeList(cmd.Context(), volume.ListOptions{})
list, err := dockerCLI.Client().VolumeList(cmd.Context(), client.VolumeListOptions{})
if err != nil {
return []string{}
}

View File

@@ -14,6 +14,7 @@ import (
"github.com/moby/moby/api/types/swarm"
"github.com/moby/moby/api/types/system"
"github.com/moby/moby/api/types/volume"
"github.com/moby/moby/client"
"github.com/spf13/cobra"
"gotest.tools/v3/assert"
)
@@ -89,7 +90,7 @@ func TestCompleteEventFilter(t *testing.T) {
},
{
client: &fakeClient{
networkListFunc: func(_ context.Context, _ network.ListOptions) ([]network.Summary, error) {
networkListFunc: func(_ context.Context, _ client.NetworkListOptions) ([]network.Summary, error) {
return []network.Summary{
*builders.NetworkResource(builders.NetworkResourceName("nw1")),
*builders.NetworkResource(builders.NetworkResourceName("nw2")),
@@ -101,7 +102,7 @@ func TestCompleteEventFilter(t *testing.T) {
},
{
client: &fakeClient{
networkListFunc: func(_ context.Context, _ network.ListOptions) ([]network.Summary, error) {
networkListFunc: func(_ context.Context, _ client.NetworkListOptions) ([]network.Summary, error) {
return nil, errors.New("API error")
},
},
@@ -110,7 +111,7 @@ func TestCompleteEventFilter(t *testing.T) {
},
{
client: &fakeClient{
nodeListFunc: func(_ context.Context, _ swarm.NodeListOptions) ([]swarm.Node, error) {
nodeListFunc: func(_ context.Context, _ client.NodeListOptions) ([]swarm.Node, error) {
return []swarm.Node{
*builders.Node(builders.Hostname("n1")),
}, nil
@@ -121,7 +122,7 @@ func TestCompleteEventFilter(t *testing.T) {
},
{
client: &fakeClient{
nodeListFunc: func(_ context.Context, _ swarm.NodeListOptions) ([]swarm.Node, error) {
nodeListFunc: func(_ context.Context, _ client.NodeListOptions) ([]swarm.Node, error) {
return []swarm.Node{}, errors.New("API error")
},
},
@@ -130,7 +131,7 @@ func TestCompleteEventFilter(t *testing.T) {
},
{
client: &fakeClient{
volumeListFunc: func(ctx context.Context, options volume.ListOptions) (volume.ListResponse, error) {
volumeListFunc: func(ctx context.Context, options client.VolumeListOptions) (volume.ListResponse, error) {
return volume.ListResponse{
Volumes: []*volume.Volume{
builders.Volume(builders.VolumeName("v1")),
@@ -144,7 +145,7 @@ func TestCompleteEventFilter(t *testing.T) {
},
{
client: &fakeClient{
volumeListFunc: func(ctx context.Context, options volume.ListOptions) (volume.ListResponse, error) {
volumeListFunc: func(ctx context.Context, options client.VolumeListOptions) (volume.ListResponse, error) {
return volume.ListResponse{}, errors.New("API error")
},
},

View File

@@ -8,7 +8,7 @@ import (
"github.com/docker/cli/cli/command/completion"
"github.com/docker/cli/cli/command/formatter"
flagsHelper "github.com/docker/cli/cli/flags"
"github.com/moby/moby/api/types/system"
"github.com/moby/moby/client"
"github.com/spf13/cobra"
)
@@ -42,7 +42,7 @@ func newDiskUsageCommand(dockerCli command.Cli) *cobra.Command {
func runDiskUsage(ctx context.Context, dockerCli command.Cli, opts diskUsageOptions) error {
// TODO expose types.DiskUsageOptions.Types as flag on the command-line and/or as separate commands (docker container df / docker container usage)
du, err := dockerCli.Client().DiskUsage(ctx, system.DiskUsageOptions{})
du, err := dockerCli.Client().DiskUsage(ctx, client.DiskUsageOptions{})
if err != nil {
return err
}

View File

@@ -17,6 +17,7 @@ import (
"github.com/docker/cli/opts"
"github.com/docker/cli/templates"
"github.com/moby/moby/api/types/events"
"github.com/moby/moby/client"
"github.com/spf13/cobra"
)
@@ -64,7 +65,7 @@ func runEvents(ctx context.Context, dockerCLI command.Cli, options *eventsOption
}
}
ctx, cancel := context.WithCancel(ctx)
evts, errs := dockerCLI.Client().Events(ctx, events.ListOptions{
evts, errs := dockerCLI.Client().Events(ctx, client.EventsListOptions{
Since: options.since,
Until: options.until,
Filters: options.filter.Value(),

View File

@@ -10,6 +10,7 @@ import (
"github.com/docker/cli/internal/test"
"github.com/moby/moby/api/types/events"
"github.com/moby/moby/client"
"gotest.tools/v3/assert"
"gotest.tools/v3/golden"
)
@@ -59,7 +60,7 @@ func TestEventsFormat(t *testing.T) {
// Set to UTC timezone as timestamps in output are
// printed in the current timezone
t.Setenv("TZ", "UTC")
cli := test.NewFakeCli(&fakeClient{eventsFn: func(context.Context, events.ListOptions) (<-chan events.Message, <-chan error) {
fakeCLI := test.NewFakeCli(&fakeClient{eventsFn: func(context.Context, client.EventsListOptions) (<-chan events.Message, <-chan error) {
messages := make(chan events.Message)
errs := make(chan error, 1)
go func() {
@@ -70,14 +71,14 @@ func TestEventsFormat(t *testing.T) {
}()
return messages, errs
}})
cmd := newEventsCommand(cli)
cmd := newEventsCommand(fakeCLI)
cmd.SetArgs(tc.args)
cmd.SetOut(io.Discard)
cmd.SetErr(io.Discard)
assert.Check(t, cmd.Execute())
out := cli.OutBuffer().String()
out := fakeCLI.OutBuffer().String()
assert.Check(t, golden.String(out, fmt.Sprintf("docker-events-%s.golden", strings.ReplaceAll(tc.name, " ", "-"))))
cli.OutBuffer().Reset()
fakeCLI.OutBuffer().Reset()
})
}
}

View File

@@ -16,8 +16,6 @@ import (
"github.com/docker/cli/cli/command/inspect"
flagsHelper "github.com/docker/cli/cli/flags"
"github.com/moby/moby/api/types/image"
"github.com/moby/moby/api/types/network"
"github.com/moby/moby/api/types/swarm"
"github.com/moby/moby/client"
"github.com/pkg/errors"
"github.com/spf13/cobra"
@@ -124,7 +122,7 @@ func inspectImages(ctx context.Context, dockerCli command.Cli) inspect.GetRefFun
func inspectNetwork(ctx context.Context, dockerCli command.Cli) inspect.GetRefFunc {
return func(ref string) (any, []byte, error) {
return dockerCli.Client().NetworkInspectWithRaw(ctx, ref, network.InspectOptions{})
return dockerCli.Client().NetworkInspectWithRaw(ctx, ref, client.NetworkInspectOptions{})
}
}
@@ -137,7 +135,7 @@ func inspectNode(ctx context.Context, dockerCli command.Cli) inspect.GetRefFunc
func inspectService(ctx context.Context, dockerCli command.Cli) inspect.GetRefFunc {
return func(ref string) (any, []byte, error) {
// Service inspect shows defaults values in empty fields.
return dockerCli.Client().ServiceInspectWithRaw(ctx, ref, swarm.ServiceInspectOptions{InsertDefaults: true})
return dockerCli.Client().ServiceInspectWithRaw(ctx, ref, client.ServiceInspectOptions{InsertDefaults: true})
}
}

View File

@@ -10,7 +10,7 @@ import (
type fakeClient struct {
client.APIClient
nodeInspectWithRaw func(ref string) (swarm.Node, []byte, error)
serviceInspectWithRaw func(ref string, options swarm.ServiceInspectOptions) (swarm.Service, []byte, error)
serviceInspectWithRaw func(ref string, options client.ServiceInspectOptions) (swarm.Service, []byte, error)
}
func (cli *fakeClient) NodeInspectWithRaw(_ context.Context, ref string) (swarm.Node, []byte, error) {
@@ -20,7 +20,7 @@ func (cli *fakeClient) NodeInspectWithRaw(_ context.Context, ref string) (swarm.
return swarm.Node{}, nil, nil
}
func (cli *fakeClient) ServiceInspectWithRaw(_ context.Context, ref string, options swarm.ServiceInspectOptions) (swarm.Service, []byte, error) {
func (cli *fakeClient) ServiceInspectWithRaw(_ context.Context, ref string, options client.ServiceInspectOptions) (swarm.Service, []byte, error) {
if cli.serviceInspectWithRaw != nil {
return cli.serviceInspectWithRaw(ref, options)
}

View File

@@ -10,13 +10,14 @@ import (
"github.com/docker/cli/internal/test"
"github.com/docker/cli/internal/test/builders"
"github.com/moby/moby/api/types/swarm"
"github.com/moby/moby/client"
"gotest.tools/v3/assert"
"gotest.tools/v3/golden"
)
func TestTaskPrintSorted(t *testing.T) {
apiClient := &fakeClient{
serviceInspectWithRaw: func(ref string, options swarm.ServiceInspectOptions) (swarm.Service, []byte, error) {
serviceInspectWithRaw: func(ref string, options client.ServiceInspectOptions) (swarm.Service, []byte, error) {
if ref == "service-id-one" {
return *builders.Service(builders.ServiceName("service-name-1")), nil, nil
}
@@ -108,7 +109,7 @@ func TestTaskPrintWithIndentation(t *testing.T) {
const trunc = false
const noResolve = false
apiClient := &fakeClient{
serviceInspectWithRaw: func(ref string, options swarm.ServiceInspectOptions) (swarm.Service, []byte, error) {
serviceInspectWithRaw: func(ref string, options client.ServiceInspectOptions) (swarm.Service, []byte, error) {
return *builders.Service(builders.ServiceName("service-name-foo")), nil, nil
},
nodeInspectWithRaw: func(ref string) (swarm.Node, []byte, error) {
@@ -144,7 +145,7 @@ func TestTaskPrintWithResolution(t *testing.T) {
const trunc = false
const noResolve = false
apiClient := &fakeClient{
serviceInspectWithRaw: func(ref string, options swarm.ServiceInspectOptions) (swarm.Service, []byte, error) {
serviceInspectWithRaw: func(ref string, options client.ServiceInspectOptions) (swarm.Service, []byte, error) {
return *builders.Service(builders.ServiceName("service-name-foo")), nil, nil
},
nodeInspectWithRaw: func(ref string) (swarm.Node, []byte, error) {

View File

@@ -13,8 +13,8 @@ import (
"github.com/docker/cli/cli"
"github.com/docker/cli/cli/command"
"github.com/docker/cli/cli/trust"
"github.com/moby/moby/api/pkg/authconfig"
imagetypes "github.com/moby/moby/api/types/image"
registrytypes "github.com/moby/moby/api/types/registry"
"github.com/moby/moby/client"
"github.com/spf13/cobra"
notaryclient "github.com/theupdateframework/notary/client"
@@ -93,7 +93,7 @@ func runSignImage(ctx context.Context, dockerCLI command.Cli, options signOption
_, _ = fmt.Fprintf(dockerCLI.Err(), "Signing and pushing trust data for local image %s, may overwrite remote trust data\n", imageName)
authConfig := command.ResolveAuthConfig(dockerCLI.ConfigFile(), imgRefAndAuth.RepoInfo().Index)
encodedAuth, err := registrytypes.EncodeAuthConfig(authConfig)
encodedAuth, err := authconfig.Encode(authConfig)
if err != nil {
return err
}

View File

@@ -31,7 +31,7 @@ func (c *fakeClient) VolumeInspect(_ context.Context, volumeID string) (volume.V
return volume.Volume{}, nil
}
func (c *fakeClient) VolumeList(_ context.Context, options volume.ListOptions) (volume.ListResponse, error) {
func (c *fakeClient) VolumeList(_ context.Context, options client.VolumeListOptions) (volume.ListResponse, error) {
if c.volumeListFunc != nil {
return c.volumeListFunc(options.Filters)
}

View File

@@ -11,7 +11,7 @@ import (
flagsHelper "github.com/docker/cli/cli/flags"
"github.com/docker/cli/opts"
"github.com/fvbommel/sortorder"
"github.com/moby/moby/api/types/volume"
"github.com/moby/moby/client"
"github.com/spf13/cobra"
)
@@ -53,7 +53,7 @@ func newListCommand(dockerCli command.Cli) *cobra.Command {
func runList(ctx context.Context, dockerCLI command.Cli, options listOptions) error {
apiClient := dockerCLI.Client()
volumes, err := apiClient.VolumeList(ctx, volume.ListOptions{Filters: options.filter.Value()})
volumes, err := apiClient.VolumeList(ctx, client.VolumeListOptions{Filters: options.filter.Value()})
if err != nil {
return err
}

View File

@@ -571,7 +571,7 @@ func TestConvertServiceConfigs(t *testing.T) {
},
}
apiClient := &fakeClient{
configListFunc: func(opts swarm.ConfigListOptions) ([]swarm.Config, error) {
configListFunc: func(opts client.ConfigListOptions) ([]swarm.Config, error) {
assert.Check(t, is.Contains(opts.Filters.Get("name"), "foo_config"))
assert.Check(t, is.Contains(opts.Filters.Get("name"), "bar_config"))
assert.Check(t, is.Contains(opts.Filters.Get("name"), "baz_config"))
@@ -615,7 +615,7 @@ func TestConvertServiceConfigs(t *testing.T) {
type fakeClient struct {
client.Client
secretListFunc func(swarm.SecretListOptions) ([]swarm.Secret, error)
configListFunc func(swarm.ConfigListOptions) ([]swarm.Config, error)
configListFunc func(client.ConfigListOptions) ([]swarm.Config, error)
}
func (c *fakeClient) SecretList(_ context.Context, options swarm.SecretListOptions) ([]swarm.Secret, error) {
@@ -625,7 +625,7 @@ func (c *fakeClient) SecretList(_ context.Context, options swarm.SecretListOptio
return []swarm.Secret{}, nil
}
func (c *fakeClient) ConfigList(_ context.Context, options swarm.ConfigListOptions) ([]swarm.Config, error) {
func (c *fakeClient) ConfigList(_ context.Context, options client.ConfigListOptions) ([]swarm.Config, error) {
if c.configListFunc != nil {
return c.configListFunc(options)
}

View File

@@ -45,12 +45,12 @@ func WithName(name string) func(*container.Summary) {
}
// WithPort adds a port mapping to the container
func WithPort(privatePort, publicPort uint16, builders ...func(*container.Port)) func(*container.Summary) {
func WithPort(privatePort, publicPort uint16, builders ...func(summary *container.PortSummary)) func(*container.Summary) {
return func(c *container.Summary) {
if c.Ports == nil {
c.Ports = []container.Port{}
c.Ports = []container.PortSummary{}
}
port := &container.Port{
port := &container.PortSummary{
PrivatePort: privatePort,
PublicPort: publicPort,
}
@@ -71,18 +71,18 @@ func WithSize(size int64) func(*container.Summary) {
}
// IP sets the ip of the port
func IP(ip string) func(*container.Port) {
return func(p *container.Port) {
func IP(ip string) func(*container.PortSummary) {
return func(p *container.PortSummary) {
p.IP = ip
}
}
// TCP sets the port to tcp
func TCP(p *container.Port) {
func TCP(p *container.PortSummary) {
p.Type = "tcp"
}
// UDP sets the port to udp
func UDP(p *container.Port) {
func UDP(p *container.PortSummary) {
p.Type = "udp"
}

View File

@@ -10,11 +10,11 @@ import (
// FakeClient is a fake NetworkAPIClient
type FakeClient struct {
client.NetworkAPIClient
NetworkInspectFunc func(ctx context.Context, networkID string, options network.InspectOptions) (network.Inspect, error)
NetworkInspectFunc func(ctx context.Context, networkID string, options client.NetworkInspectOptions) (network.Inspect, error)
}
// NetworkInspect fakes inspecting a network
func (c *FakeClient) NetworkInspect(ctx context.Context, networkID string, options network.InspectOptions) (network.Inspect, error) {
func (c *FakeClient) NetworkInspect(ctx context.Context, networkID string, options client.NetworkInspectOptions) (network.Inspect, error) {
if c.NetworkInspectFunc != nil {
return c.NetworkInspectFunc(ctx, networkID, options)
}

View File

@@ -28,8 +28,8 @@ require (
github.com/google/uuid v1.6.0
github.com/mattn/go-runewidth v0.0.16
github.com/moby/go-archive v0.1.0
github.com/moby/moby/api v1.52.0-alpha.1
github.com/moby/moby/client v0.1.0-alpha.0
github.com/moby/moby/api v1.52.0-alpha.1.0.20250826164402-7145e7666b8f // master
github.com/moby/moby/client v0.1.0-alpha.0.0.20250826164402-7145e7666b8f // master
github.com/moby/patternmatcher v0.6.0
github.com/moby/swarmkit/v2 v2.0.0
github.com/moby/sys/atomicwriter v0.1.0

View File

@@ -170,10 +170,10 @@ github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3N
github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo=
github.com/moby/go-archive v0.1.0 h1:Kk/5rdW/g+H8NHdJW2gsXyZ7UnzvJNOy6VKJqueWdcQ=
github.com/moby/go-archive v0.1.0/go.mod h1:G9B+YoujNohJmrIYFBpSd54GTUB4lt9S+xVQvsJyFuo=
github.com/moby/moby/api v1.52.0-alpha.1 h1:fzxPD0h6l4LmvPd/rySW7T3G45G8eFTo9qEAEp5UZX0=
github.com/moby/moby/api v1.52.0-alpha.1/go.mod h1:MuA35dxT3DVZpImg0ORGCoZtT2dC1jgPjwH9/CQ/afQ=
github.com/moby/moby/client v0.1.0-alpha.0 h1:1Q393KgwO8L3SznKE+xGZJVDdApgcSM0vIhAEff+acc=
github.com/moby/moby/client v0.1.0-alpha.0/go.mod h1:pVMvmGeD4P9tbgBtEHZKW993Qkj4d1Nu6qhiW3GGJ6k=
github.com/moby/moby/api v1.52.0-alpha.1.0.20250826164402-7145e7666b8f h1:faKJR1203hI97HWd0Y4cNBEKLy4nWdkjYpqP4D+j+nk=
github.com/moby/moby/api v1.52.0-alpha.1.0.20250826164402-7145e7666b8f/go.mod h1:8sBV0soUREiudtow4vqJGOxa4GyHI5vLQmvgKdHq5Ok=
github.com/moby/moby/client v0.1.0-alpha.0.0.20250826164402-7145e7666b8f h1:AoyUekdtDsiajk9W2+n0zWR+926oRcuy9AHZSX0whJw=
github.com/moby/moby/client v0.1.0-alpha.0.0.20250826164402-7145e7666b8f/go.mod h1:7pOYrEHdG7I0dNZEC+yqk/p8ZOxGMR1KgoexzCEDe0w=
github.com/moby/patternmatcher v0.6.0 h1:GmP9lR19aU5GqSSFko+5pRqHi+Ohk1O69aFiKkVGiPk=
github.com/moby/patternmatcher v0.6.0/go.mod h1:hDPoyOpDY7OrrMDLaYoY3hf52gNCR/YOUYxkhApJIxc=
github.com/moby/swarmkit/v2 v2.0.0 h1:jkWQKQaJ4ltA61/mC9UdPe1McLma55RUcacTO+pPweY=

View File

@@ -0,0 +1,92 @@
package authconfig
import (
"bytes"
"encoding/base64"
"encoding/json"
"errors"
"fmt"
"io"
"github.com/moby/moby/api/types/registry"
)
// Encode serializes the auth configuration as a base64url encoded
// ([RFC4648, section 5]) JSON string for sending through the X-Registry-Auth header.
//
// [RFC4648, section 5]: https://tools.ietf.org/html/rfc4648#section-5
func Encode(authConfig registry.AuthConfig) (string, error) {
// Older daemons (or registries) may not handle an empty string,
// which resulted in an "io.EOF" when unmarshaling or decoding.
//
// FIXME(thaJeztah): find exactly what code-paths are impacted by this.
// if authConfig == (AuthConfig{}) { return "", nil }
buf, err := json.Marshal(authConfig)
if err != nil {
return "", errInvalidParameter{err}
}
return base64.URLEncoding.EncodeToString(buf), nil
}
// Decode decodes base64url encoded ([RFC4648, section 5]) JSON
// authentication information as sent through the X-Registry-Auth header.
//
// This function always returns an [AuthConfig], even if an error occurs. It is up
// to the caller to decide if authentication is required, and if the error can
// be ignored.
//
// [RFC4648, section 5]: https://tools.ietf.org/html/rfc4648#section-5
func Decode(authEncoded string) (*registry.AuthConfig, error) {
if authEncoded == "" {
return &registry.AuthConfig{}, nil
}
decoded, err := base64.URLEncoding.DecodeString(authEncoded)
if err != nil {
var e base64.CorruptInputError
if errors.As(err, &e) {
return &registry.AuthConfig{}, invalid(errors.New("must be a valid base64url-encoded string"))
}
return &registry.AuthConfig{}, invalid(err)
}
if bytes.Equal(decoded, []byte("{}")) {
return &registry.AuthConfig{}, nil
}
return decode(bytes.NewReader(decoded))
}
// DecodeRequestBody decodes authentication information as sent as JSON in the
// body of a request. This function is to provide backward compatibility with old
// clients and API versions. Current clients and API versions expect authentication
// to be provided through the X-Registry-Auth header.
//
// Like [Decode], this function always returns an [AuthConfig], even if an
// error occurs. It is up to the caller to decide if authentication is required,
// and if the error can be ignored.
func DecodeRequestBody(r io.ReadCloser) (*registry.AuthConfig, error) {
return decode(r)
}
func decode(r io.Reader) (*registry.AuthConfig, error) {
authConfig := &registry.AuthConfig{}
if err := json.NewDecoder(r).Decode(authConfig); err != nil {
// always return an (empty) AuthConfig to increase compatibility with
// the existing API.
return &registry.AuthConfig{}, invalid(fmt.Errorf("invalid JSON: %w", err))
}
return authConfig, nil
}
func invalid(err error) error {
return errInvalidParameter{fmt.Errorf("invalid X-Registry-Auth header: %w", err)}
}
type errInvalidParameter struct{ error }
func (errInvalidParameter) InvalidParameter() {}
func (e errInvalidParameter) Cause() error { return e.error }
func (e errInvalidParameter) Unwrap() error { return e.error }

View File

@@ -1,8 +0,0 @@
package build
// CacheDiskUsage contains disk usage for the build cache.
type CacheDiskUsage struct {
TotalSize int64
Reclaimable int64
Items []*CacheRecord
}

View File

@@ -4,7 +4,6 @@ import (
"time"
dockerspec "github.com/moby/docker-image-spec/specs-go/v1"
"github.com/moby/moby/api/types/strslice"
)
// MinimumDuration puts a minimum on user configured duration.
@@ -52,13 +51,13 @@ type Config struct {
OpenStdin bool // Open stdin
StdinOnce bool // If true, close stdin after the 1 attached client disconnects.
Env []string // List of environment variable to set in the container
Cmd strslice.StrSlice // Command to run when starting the container
Cmd []string // Command to run when starting the container
Healthcheck *HealthConfig `json:",omitempty"` // Healthcheck describes how to check the container is healthy
ArgsEscaped bool `json:",omitempty"` // True if command is already escaped (meaning treat as a command line) (Windows specific).
Image string // Name of the image as it was passed by the operator (e.g. could be symbolic)
Volumes map[string]struct{} // List of volumes (mounts) used for the container
WorkingDir string // Current directory (PWD) in the command will be launched
Entrypoint strslice.StrSlice // Entrypoint to run when starting the container
Entrypoint []string // Entrypoint to run when starting the container
NetworkDisabled bool `json:",omitempty"` // Is network disabled
// Mac Address of the container.
//
@@ -68,5 +67,5 @@ type Config struct {
Labels map[string]string // List of labels set to this container
StopSignal string `json:",omitempty"` // Signal to stop a container
StopTimeout *int `json:",omitempty"` // Timeout (in seconds) to stop a container
Shell strslice.StrSlice `json:",omitempty"` // Shell for shell-form of RUN, CMD, ENTRYPOINT
Shell []string `json:",omitempty"` // Shell for shell-form of RUN, CMD, ENTRYPOINT
}

View File

@@ -104,7 +104,7 @@ type Summary struct {
ImageManifestDescriptor *ocispec.Descriptor `json:"ImageManifestDescriptor,omitempty"`
Command string
Created int64
Ports []Port
Ports []PortSummary
SizeRw int64 `json:",omitempty"`
SizeRootFs int64 `json:",omitempty"`
Labels map[string]string

View File

@@ -1,8 +0,0 @@
package container
// DiskUsage contains disk usage for containers.
type DiskUsage struct {
TotalSize int64
Reclaimable int64
Items []*Summary
}

View File

@@ -9,7 +9,6 @@ import (
"github.com/moby/moby/api/types/blkiodev"
"github.com/moby/moby/api/types/mount"
"github.com/moby/moby/api/types/network"
"github.com/moby/moby/api/types/strslice"
)
// CgroupnsMode represents the cgroup namespace mode of the container
@@ -435,8 +434,8 @@ type HostConfig struct {
Annotations map[string]string `json:",omitempty"` // Arbitrary non-identifying metadata attached to container and provided to the runtime
// Applicable to UNIX platforms
CapAdd strslice.StrSlice // List of kernel capabilities to add to the container
CapDrop strslice.StrSlice // List of kernel capabilities to remove from the container
CapAdd []string // List of kernel capabilities to add to the container
CapDrop []string // List of kernel capabilities to remove from the container
CgroupnsMode CgroupnsMode // Cgroup namespace mode to use for the container
DNS []string `json:"Dns"` // List of DNS server to lookup
DNSOptions []string `json:"DnsOptions"` // List of DNSOption to look for

View File

@@ -2,14 +2,6 @@ package container
import "github.com/moby/moby/api/types/filters"
// 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
}
// AttachOptions holds parameters to attach to a container.
type AttachOptions struct {
Stream bool

View File

@@ -5,11 +5,12 @@ package container
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
// Port An open port on a container
// PortSummary Describes a port-mapping between the container and the host.
//
// Example: {"PrivatePort":8080,"PublicPort":80,"Type":"tcp"}
//
// swagger:model Port
type Port struct {
// swagger:model PortSummary
type PortSummary struct {
// Host IP address that the container's port is mapped to
IP string `json:"IP,omitempty"`

Some files were not shown because too many files have changed in this diff Show More