Merge pull request #6084 from thaJeztah/bump_engine
vendor: github.com/docker/docker 8601b22f5db5 (v28.2-dev)
This commit is contained in:
commit
af090512a6
@ -3,7 +3,6 @@ package idresolver
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
|
||||||
"github.com/docker/docker/api/types/swarm"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
"github.com/docker/docker/client"
|
"github.com/docker/docker/client"
|
||||||
)
|
)
|
||||||
@ -21,7 +20,7 @@ func (cli *fakeClient) NodeInspectWithRaw(_ context.Context, nodeID string) (swa
|
|||||||
return swarm.Node{}, []byte{}, nil
|
return swarm.Node{}, []byte{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cli *fakeClient) ServiceInspectWithRaw(_ context.Context, serviceID string, _ types.ServiceInspectOptions) (swarm.Service, []byte, error) {
|
func (cli *fakeClient) ServiceInspectWithRaw(_ context.Context, serviceID string, _ swarm.ServiceInspectOptions) (swarm.Service, []byte, error) {
|
||||||
if cli.serviceInspectFunc != nil {
|
if cli.serviceInspectFunc != nil {
|
||||||
return cli.serviceInspectFunc(serviceID)
|
return cli.serviceInspectFunc(serviceID)
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,6 @@ package idresolver
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
|
||||||
"github.com/docker/docker/api/types/swarm"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
"github.com/docker/docker/client"
|
"github.com/docker/docker/client"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
@ -44,7 +43,7 @@ func (r *IDResolver) get(ctx context.Context, t any, id string) (string, error)
|
|||||||
}
|
}
|
||||||
return id, nil
|
return id, nil
|
||||||
case swarm.Service:
|
case swarm.Service:
|
||||||
service, _, err := r.client.ServiceInspectWithRaw(ctx, id, types.ServiceInspectOptions{})
|
service, _, err := r.client.ServiceInspectWithRaw(ctx, id, swarm.ServiceInspectOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// TODO(thaJeztah): should error-handling be more specific, or is it ok to ignore any error?
|
// 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.
|
return id, nil //nolint:nilerr // ignore nil-error being returned, as this is a best-effort.
|
||||||
|
@ -3,7 +3,6 @@ package node
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
|
||||||
"github.com/docker/docker/api/types/swarm"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
"github.com/docker/docker/api/types/system"
|
"github.com/docker/docker/api/types/system"
|
||||||
"github.com/docker/docker/client"
|
"github.com/docker/docker/client"
|
||||||
@ -17,8 +16,8 @@ type fakeClient struct {
|
|||||||
nodeRemoveFunc func() error
|
nodeRemoveFunc func() error
|
||||||
nodeUpdateFunc func(nodeID string, version swarm.Version, node swarm.NodeSpec) error
|
nodeUpdateFunc func(nodeID string, version swarm.Version, node swarm.NodeSpec) error
|
||||||
taskInspectFunc func(taskID string) (swarm.Task, []byte, error)
|
taskInspectFunc func(taskID string) (swarm.Task, []byte, error)
|
||||||
taskListFunc func(options types.TaskListOptions) ([]swarm.Task, error)
|
taskListFunc func(options swarm.TaskListOptions) ([]swarm.Task, error)
|
||||||
serviceInspectFunc func(ctx context.Context, serviceID string, opts types.ServiceInspectOptions) (swarm.Service, []byte, error)
|
serviceInspectFunc func(ctx context.Context, serviceID string, opts swarm.ServiceInspectOptions) (swarm.Service, []byte, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cli *fakeClient) NodeInspectWithRaw(context.Context, string) (swarm.Node, []byte, error) {
|
func (cli *fakeClient) NodeInspectWithRaw(context.Context, string) (swarm.Node, []byte, error) {
|
||||||
@ -28,14 +27,14 @@ func (cli *fakeClient) NodeInspectWithRaw(context.Context, string) (swarm.Node,
|
|||||||
return swarm.Node{}, []byte{}, nil
|
return swarm.Node{}, []byte{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cli *fakeClient) NodeList(context.Context, types.NodeListOptions) ([]swarm.Node, error) {
|
func (cli *fakeClient) NodeList(context.Context, swarm.NodeListOptions) ([]swarm.Node, error) {
|
||||||
if cli.nodeListFunc != nil {
|
if cli.nodeListFunc != nil {
|
||||||
return cli.nodeListFunc()
|
return cli.nodeListFunc()
|
||||||
}
|
}
|
||||||
return []swarm.Node{}, nil
|
return []swarm.Node{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cli *fakeClient) NodeRemove(context.Context, string, types.NodeRemoveOptions) error {
|
func (cli *fakeClient) NodeRemove(context.Context, string, swarm.NodeRemoveOptions) error {
|
||||||
if cli.nodeRemoveFunc != nil {
|
if cli.nodeRemoveFunc != nil {
|
||||||
return cli.nodeRemoveFunc()
|
return cli.nodeRemoveFunc()
|
||||||
}
|
}
|
||||||
@ -63,14 +62,14 @@ func (cli *fakeClient) TaskInspectWithRaw(_ context.Context, taskID string) (swa
|
|||||||
return swarm.Task{}, []byte{}, nil
|
return swarm.Task{}, []byte{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cli *fakeClient) TaskList(_ context.Context, options types.TaskListOptions) ([]swarm.Task, error) {
|
func (cli *fakeClient) TaskList(_ context.Context, options swarm.TaskListOptions) ([]swarm.Task, error) {
|
||||||
if cli.taskListFunc != nil {
|
if cli.taskListFunc != nil {
|
||||||
return cli.taskListFunc(options)
|
return cli.taskListFunc(options)
|
||||||
}
|
}
|
||||||
return []swarm.Task{}, nil
|
return []swarm.Task{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cli *fakeClient) ServiceInspectWithRaw(ctx context.Context, serviceID string, opts types.ServiceInspectOptions) (swarm.Service, []byte, error) {
|
func (cli *fakeClient) ServiceInspectWithRaw(ctx context.Context, serviceID string, opts swarm.ServiceInspectOptions) (swarm.Service, []byte, error) {
|
||||||
if cli.serviceInspectFunc != nil {
|
if cli.serviceInspectFunc != nil {
|
||||||
return cli.serviceInspectFunc(ctx, serviceID, opts)
|
return cli.serviceInspectFunc(ctx, serviceID, opts)
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import (
|
|||||||
|
|
||||||
"github.com/docker/cli/cli"
|
"github.com/docker/cli/cli"
|
||||||
"github.com/docker/cli/cli/command"
|
"github.com/docker/cli/cli/command"
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
"github.com/docker/docker/client"
|
"github.com/docker/docker/client"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
@ -48,7 +48,7 @@ func Reference(ctx context.Context, apiClient client.APIClient, ref string) (str
|
|||||||
// If there's no node ID in /info, the node probably
|
// If there's no node ID in /info, the node probably
|
||||||
// isn't a manager. Call a swarm-specific endpoint to
|
// isn't a manager. Call a swarm-specific endpoint to
|
||||||
// get a more specific error message.
|
// get a more specific error message.
|
||||||
_, err = apiClient.NodeList(ctx, types.NodeListOptions{})
|
_, err = apiClient.NodeList(ctx, swarm.NodeListOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/docker/cli/cli/command/completion"
|
"github.com/docker/cli/cli/command/completion"
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
"github.com/spf13/cobra"
|
"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
|
// https://github.com/docker/cli/blob/f9ced58158d5e0b358052432244b483774a1983d/contrib/completion/bash/docker#L41-L43
|
||||||
showIDs := os.Getenv("DOCKER_COMPLETION_SHOW_NODE_IDS") == "yes"
|
showIDs := os.Getenv("DOCKER_COMPLETION_SHOW_NODE_IDS") == "yes"
|
||||||
return func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
return func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||||
list, err := dockerCLI.Client().NodeList(cmd.Context(), types.NodeListOptions{})
|
list, err := dockerCLI.Client().NodeList(cmd.Context(), swarm.NodeListOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, cobra.ShellCompDirectiveError
|
return nil, cobra.ShellCompDirectiveError
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ import (
|
|||||||
"github.com/docker/cli/cli/command/formatter"
|
"github.com/docker/cli/cli/command/formatter"
|
||||||
flagsHelper "github.com/docker/cli/cli/flags"
|
flagsHelper "github.com/docker/cli/cli/flags"
|
||||||
"github.com/docker/cli/opts"
|
"github.com/docker/cli/opts"
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
"github.com/docker/docker/api/types/system"
|
"github.com/docker/docker/api/types/system"
|
||||||
"github.com/fvbommel/sortorder"
|
"github.com/fvbommel/sortorder"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
@ -55,7 +55,7 @@ func runList(ctx context.Context, dockerCli command.Cli, options listOptions) er
|
|||||||
|
|
||||||
nodes, err := client.NodeList(
|
nodes, err := client.NodeList(
|
||||||
ctx,
|
ctx,
|
||||||
types.NodeListOptions{Filters: options.filter.Value()})
|
swarm.NodeListOptions{Filters: options.filter.Value()})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,6 @@ import (
|
|||||||
"github.com/docker/cli/cli/command/idresolver"
|
"github.com/docker/cli/cli/command/idresolver"
|
||||||
"github.com/docker/cli/cli/command/task"
|
"github.com/docker/cli/cli/command/task"
|
||||||
"github.com/docker/cli/opts"
|
"github.com/docker/cli/opts"
|
||||||
"github.com/docker/docker/api/types"
|
|
||||||
"github.com/docker/docker/api/types/swarm"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
@ -84,7 +83,7 @@ func runPs(ctx context.Context, dockerCli command.Cli, options psOptions) error
|
|||||||
filter := options.filter.Value()
|
filter := options.filter.Value()
|
||||||
filter.Add("node", node.ID)
|
filter.Add("node", node.ID)
|
||||||
|
|
||||||
nodeTasks, err := client.TaskList(ctx, types.TaskListOptions{Filters: filter})
|
nodeTasks, err := client.TaskList(ctx, swarm.TaskListOptions{Filters: filter})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errs = append(errs, err.Error())
|
errs = append(errs, err.Error())
|
||||||
continue
|
continue
|
||||||
|
@ -10,7 +10,6 @@ import (
|
|||||||
|
|
||||||
"github.com/docker/cli/internal/test"
|
"github.com/docker/cli/internal/test"
|
||||||
"github.com/docker/cli/internal/test/builders"
|
"github.com/docker/cli/internal/test/builders"
|
||||||
"github.com/docker/docker/api/types"
|
|
||||||
"github.com/docker/docker/api/types/swarm"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
"github.com/docker/docker/api/types/system"
|
"github.com/docker/docker/api/types/system"
|
||||||
"gotest.tools/v3/assert"
|
"gotest.tools/v3/assert"
|
||||||
@ -23,7 +22,7 @@ func TestNodePsErrors(t *testing.T) {
|
|||||||
flags map[string]string
|
flags map[string]string
|
||||||
infoFunc func() (system.Info, error)
|
infoFunc func() (system.Info, error)
|
||||||
nodeInspectFunc func() (swarm.Node, []byte, error)
|
nodeInspectFunc func() (swarm.Node, []byte, error)
|
||||||
taskListFunc func(options types.TaskListOptions) ([]swarm.Task, error)
|
taskListFunc func(options swarm.TaskListOptions) ([]swarm.Task, error)
|
||||||
taskInspectFunc func(taskID string) (swarm.Task, []byte, error)
|
taskInspectFunc func(taskID string) (swarm.Task, []byte, error)
|
||||||
expectedError string
|
expectedError string
|
||||||
}{
|
}{
|
||||||
@ -42,7 +41,7 @@ func TestNodePsErrors(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
args: []string{"nodeID"},
|
args: []string{"nodeID"},
|
||||||
taskListFunc: func(options types.TaskListOptions) ([]swarm.Task, error) {
|
taskListFunc: func(options swarm.TaskListOptions) ([]swarm.Task, error) {
|
||||||
return []swarm.Task{}, errors.New("error returning the task list")
|
return []swarm.Task{}, errors.New("error returning the task list")
|
||||||
},
|
},
|
||||||
expectedError: "error returning the task list",
|
expectedError: "error returning the task list",
|
||||||
@ -73,9 +72,9 @@ func TestNodePs(t *testing.T) {
|
|||||||
flags map[string]string
|
flags map[string]string
|
||||||
infoFunc func() (system.Info, error)
|
infoFunc func() (system.Info, error)
|
||||||
nodeInspectFunc func() (swarm.Node, []byte, error)
|
nodeInspectFunc func() (swarm.Node, []byte, error)
|
||||||
taskListFunc func(options types.TaskListOptions) ([]swarm.Task, error)
|
taskListFunc func(options swarm.TaskListOptions) ([]swarm.Task, error)
|
||||||
taskInspectFunc func(taskID string) (swarm.Task, []byte, error)
|
taskInspectFunc func(taskID string) (swarm.Task, []byte, error)
|
||||||
serviceInspectFunc func(ctx context.Context, serviceID string, opts types.ServiceInspectOptions) (swarm.Service, []byte, error)
|
serviceInspectFunc func(ctx context.Context, serviceID string, opts swarm.ServiceInspectOptions) (swarm.Service, []byte, error)
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "simple",
|
name: "simple",
|
||||||
@ -83,7 +82,7 @@ func TestNodePs(t *testing.T) {
|
|||||||
nodeInspectFunc: func() (swarm.Node, []byte, error) {
|
nodeInspectFunc: func() (swarm.Node, []byte, error) {
|
||||||
return *builders.Node(), []byte{}, nil
|
return *builders.Node(), []byte{}, nil
|
||||||
},
|
},
|
||||||
taskListFunc: func(options types.TaskListOptions) ([]swarm.Task, error) {
|
taskListFunc: func(options swarm.TaskListOptions) ([]swarm.Task, error) {
|
||||||
return []swarm.Task{
|
return []swarm.Task{
|
||||||
*builders.Task(builders.WithStatus(builders.Timestamp(time.Now().Add(-2*time.Hour)), builders.PortStatus([]swarm.PortConfig{
|
*builders.Task(builders.WithStatus(builders.Timestamp(time.Now().Add(-2*time.Hour)), builders.PortStatus([]swarm.PortConfig{
|
||||||
{
|
{
|
||||||
@ -94,7 +93,7 @@ func TestNodePs(t *testing.T) {
|
|||||||
}))),
|
}))),
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
serviceInspectFunc: func(ctx context.Context, serviceID string, opts types.ServiceInspectOptions) (swarm.Service, []byte, error) {
|
serviceInspectFunc: func(ctx context.Context, serviceID string, opts swarm.ServiceInspectOptions) (swarm.Service, []byte, error) {
|
||||||
return swarm.Service{
|
return swarm.Service{
|
||||||
ID: serviceID,
|
ID: serviceID,
|
||||||
Spec: swarm.ServiceSpec{
|
Spec: swarm.ServiceSpec{
|
||||||
@ -111,7 +110,7 @@ func TestNodePs(t *testing.T) {
|
|||||||
nodeInspectFunc: func() (swarm.Node, []byte, error) {
|
nodeInspectFunc: func() (swarm.Node, []byte, error) {
|
||||||
return *builders.Node(), []byte{}, nil
|
return *builders.Node(), []byte{}, nil
|
||||||
},
|
},
|
||||||
taskListFunc: func(options types.TaskListOptions) ([]swarm.Task, error) {
|
taskListFunc: func(options swarm.TaskListOptions) ([]swarm.Task, error) {
|
||||||
return []swarm.Task{
|
return []swarm.Task{
|
||||||
*builders.Task(builders.TaskID("taskID1"), builders.TaskServiceID("failure"),
|
*builders.Task(builders.TaskID("taskID1"), builders.TaskServiceID("failure"),
|
||||||
builders.WithStatus(builders.Timestamp(time.Now().Add(-2*time.Hour)), builders.StatusErr("a task error"))),
|
builders.WithStatus(builders.Timestamp(time.Now().Add(-2*time.Hour)), builders.StatusErr("a task error"))),
|
||||||
@ -121,7 +120,7 @@ func TestNodePs(t *testing.T) {
|
|||||||
builders.WithStatus(builders.Timestamp(time.Now().Add(-4*time.Hour)), builders.StatusErr("a task error"))),
|
builders.WithStatus(builders.Timestamp(time.Now().Add(-4*time.Hour)), builders.StatusErr("a task error"))),
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
serviceInspectFunc: func(ctx context.Context, serviceID string, opts types.ServiceInspectOptions) (swarm.Service, []byte, error) {
|
serviceInspectFunc: func(ctx context.Context, serviceID string, opts swarm.ServiceInspectOptions) (swarm.Service, []byte, error) {
|
||||||
return swarm.Service{
|
return swarm.Service{
|
||||||
ID: serviceID,
|
ID: serviceID,
|
||||||
Spec: swarm.ServiceSpec{
|
Spec: swarm.ServiceSpec{
|
||||||
|
@ -7,7 +7,7 @@ import (
|
|||||||
|
|
||||||
"github.com/docker/cli/cli"
|
"github.com/docker/cli/cli"
|
||||||
"github.com/docker/cli/cli/command"
|
"github.com/docker/cli/cli/command"
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -38,7 +38,7 @@ func runRemove(ctx context.Context, dockerCLI command.Cli, nodeIDs []string, opt
|
|||||||
|
|
||||||
var errs []error
|
var errs []error
|
||||||
for _, id := range nodeIDs {
|
for _, id := range nodeIDs {
|
||||||
if err := apiClient.NodeRemove(ctx, id, types.NodeRemoveOptions{Force: opts.force}); err != nil {
|
if err := apiClient.NodeRemove(ctx, id, swarm.NodeRemoveOptions{Force: opts.force}); err != nil {
|
||||||
errs = append(errs, err)
|
errs = append(errs, err)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/docker/cli/internal/test/builders"
|
"github.com/docker/cli/internal/test/builders"
|
||||||
"github.com/docker/docker/api/types"
|
|
||||||
"github.com/docker/docker/api/types/network"
|
"github.com/docker/docker/api/types/network"
|
||||||
"github.com/docker/docker/api/types/swarm"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
"github.com/docker/docker/api/types/system"
|
"github.com/docker/docker/api/types/system"
|
||||||
@ -13,30 +12,30 @@ import (
|
|||||||
|
|
||||||
type fakeClient struct {
|
type fakeClient struct {
|
||||||
client.Client
|
client.Client
|
||||||
serviceInspectWithRawFunc func(ctx context.Context, serviceID string, options types.ServiceInspectOptions) (swarm.Service, []byte, error)
|
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 types.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error)
|
serviceUpdateFunc func(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options swarm.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error)
|
||||||
serviceListFunc func(context.Context, types.ServiceListOptions) ([]swarm.Service, error)
|
serviceListFunc func(context.Context, swarm.ServiceListOptions) ([]swarm.Service, error)
|
||||||
taskListFunc func(context.Context, types.TaskListOptions) ([]swarm.Task, error)
|
taskListFunc func(context.Context, swarm.TaskListOptions) ([]swarm.Task, error)
|
||||||
infoFunc func(ctx context.Context) (system.Info, error)
|
infoFunc func(ctx context.Context) (system.Info, error)
|
||||||
networkInspectFunc func(ctx context.Context, networkID string, options network.InspectOptions) (network.Inspect, error)
|
networkInspectFunc func(ctx context.Context, networkID string, options network.InspectOptions) (network.Inspect, error)
|
||||||
nodeListFunc func(ctx context.Context, options types.NodeListOptions) ([]swarm.Node, error)
|
nodeListFunc func(ctx context.Context, options swarm.NodeListOptions) ([]swarm.Node, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *fakeClient) NodeList(ctx context.Context, options types.NodeListOptions) ([]swarm.Node, error) {
|
func (f *fakeClient) NodeList(ctx context.Context, options swarm.NodeListOptions) ([]swarm.Node, error) {
|
||||||
if f.nodeListFunc != nil {
|
if f.nodeListFunc != nil {
|
||||||
return f.nodeListFunc(ctx, options)
|
return f.nodeListFunc(ctx, options)
|
||||||
}
|
}
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *fakeClient) TaskList(ctx context.Context, options types.TaskListOptions) ([]swarm.Task, error) {
|
func (f *fakeClient) TaskList(ctx context.Context, options swarm.TaskListOptions) ([]swarm.Task, error) {
|
||||||
if f.taskListFunc != nil {
|
if f.taskListFunc != nil {
|
||||||
return f.taskListFunc(ctx, options)
|
return f.taskListFunc(ctx, options)
|
||||||
}
|
}
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *fakeClient) ServiceInspectWithRaw(ctx context.Context, serviceID string, options types.ServiceInspectOptions) (swarm.Service, []byte, error) {
|
func (f *fakeClient) ServiceInspectWithRaw(ctx context.Context, serviceID string, options swarm.ServiceInspectOptions) (swarm.Service, []byte, error) {
|
||||||
if f.serviceInspectWithRawFunc != nil {
|
if f.serviceInspectWithRawFunc != nil {
|
||||||
return f.serviceInspectWithRawFunc(ctx, serviceID, options)
|
return f.serviceInspectWithRawFunc(ctx, serviceID, options)
|
||||||
}
|
}
|
||||||
@ -44,7 +43,7 @@ func (f *fakeClient) ServiceInspectWithRaw(ctx context.Context, serviceID string
|
|||||||
return *builders.Service(builders.ServiceID(serviceID)), []byte{}, nil
|
return *builders.Service(builders.ServiceID(serviceID)), []byte{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *fakeClient) ServiceList(ctx context.Context, options types.ServiceListOptions) ([]swarm.Service, error) {
|
func (f *fakeClient) ServiceList(ctx context.Context, options swarm.ServiceListOptions) ([]swarm.Service, error) {
|
||||||
if f.serviceListFunc != nil {
|
if f.serviceListFunc != nil {
|
||||||
return f.serviceListFunc(ctx, options)
|
return f.serviceListFunc(ctx, options)
|
||||||
}
|
}
|
||||||
@ -52,7 +51,7 @@ func (f *fakeClient) ServiceList(ctx context.Context, options types.ServiceListO
|
|||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *fakeClient) ServiceUpdate(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options types.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error) {
|
func (f *fakeClient) ServiceUpdate(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options swarm.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error) {
|
||||||
if f.serviceUpdateFunc != nil {
|
if f.serviceUpdateFunc != nil {
|
||||||
return f.serviceUpdateFunc(ctx, serviceID, version, service, options)
|
return f.serviceUpdateFunc(ctx, serviceID, version, service, options)
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/docker/cli/cli/command/completion"
|
"github.com/docker/cli/cli/command/completion"
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
"github.com/spf13/cobra"
|
"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
|
// https://github.com/docker/cli/blob/f9ced58158d5e0b358052432244b483774a1983d/contrib/completion/bash/docker#L41-L43
|
||||||
showIDs := os.Getenv("DOCKER_COMPLETION_SHOW_SERVICE_IDS") == "yes"
|
showIDs := os.Getenv("DOCKER_COMPLETION_SHOW_SERVICE_IDS") == "yes"
|
||||||
return func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
return func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
||||||
list, err := dockerCLI.Client().ServiceList(cmd.Context(), types.ServiceListOptions{})
|
list, err := dockerCLI.Client().ServiceList(cmd.Context(), swarm.ServiceListOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, cobra.ShellCompDirectiveError
|
return nil, cobra.ShellCompDirectiveError
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,6 @@ import (
|
|||||||
"github.com/docker/cli/cli/command"
|
"github.com/docker/cli/cli/command"
|
||||||
"github.com/docker/cli/cli/command/completion"
|
"github.com/docker/cli/cli/command/completion"
|
||||||
cliopts "github.com/docker/cli/opts"
|
cliopts "github.com/docker/cli/opts"
|
||||||
"github.com/docker/docker/api/types"
|
|
||||||
"github.com/docker/docker/api/types/swarm"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
"github.com/docker/docker/api/types/versions"
|
"github.com/docker/docker/api/types/versions"
|
||||||
"github.com/docker/docker/client"
|
"github.com/docker/docker/client"
|
||||||
@ -102,7 +101,7 @@ func newCreateCommand(dockerCLI command.Cli) *cobra.Command {
|
|||||||
|
|
||||||
func runCreate(ctx context.Context, dockerCLI command.Cli, flags *pflag.FlagSet, opts *serviceOptions) error {
|
func runCreate(ctx context.Context, dockerCLI command.Cli, flags *pflag.FlagSet, opts *serviceOptions) error {
|
||||||
apiClient := dockerCLI.Client()
|
apiClient := dockerCLI.Client()
|
||||||
createOpts := types.ServiceCreateOptions{}
|
createOpts := swarm.ServiceCreateOptions{}
|
||||||
|
|
||||||
service, err := opts.ToService(ctx, apiClient, flags)
|
service, err := opts.ToService(ctx, apiClient, flags)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -13,8 +13,8 @@ import (
|
|||||||
"github.com/docker/cli/cli/command/completion"
|
"github.com/docker/cli/cli/command/completion"
|
||||||
"github.com/docker/cli/cli/command/formatter"
|
"github.com/docker/cli/cli/command/formatter"
|
||||||
flagsHelper "github.com/docker/cli/cli/flags"
|
flagsHelper "github.com/docker/cli/cli/flags"
|
||||||
"github.com/docker/docker/api/types"
|
|
||||||
"github.com/docker/docker/api/types/network"
|
"github.com/docker/docker/api/types/network"
|
||||||
|
"github.com/docker/docker/api/types/swarm"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/pflag"
|
"github.com/spf13/pflag"
|
||||||
@ -66,7 +66,7 @@ func runInspect(ctx context.Context, dockerCli command.Cli, opts inspectOptions)
|
|||||||
|
|
||||||
getRef := func(ref string) (any, []byte, error) {
|
getRef := func(ref string) (any, []byte, error) {
|
||||||
// Service inspect shows defaults values in empty fields.
|
// Service inspect shows defaults values in empty fields.
|
||||||
service, _, err := client.ServiceInspectWithRaw(ctx, ref, types.ServiceInspectOptions{InsertDefaults: true})
|
service, _, err := client.ServiceInspectWithRaw(ctx, ref, swarm.ServiceInspectOptions{InsertDefaults: true})
|
||||||
if err == nil || !cerrdefs.IsNotFound(err) {
|
if err == nil || !cerrdefs.IsNotFound(err) {
|
||||||
return service, nil, err
|
return service, nil, err
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,6 @@ import (
|
|||||||
"github.com/docker/cli/cli/command/formatter"
|
"github.com/docker/cli/cli/command/formatter"
|
||||||
flagsHelper "github.com/docker/cli/cli/flags"
|
flagsHelper "github.com/docker/cli/cli/flags"
|
||||||
"github.com/docker/cli/opts"
|
"github.com/docker/cli/opts"
|
||||||
"github.com/docker/docker/api/types"
|
|
||||||
"github.com/docker/docker/api/types/filters"
|
"github.com/docker/docker/api/types/filters"
|
||||||
"github.com/docker/docker/api/types/swarm"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
"github.com/docker/docker/client"
|
"github.com/docker/docker/client"
|
||||||
@ -57,7 +56,7 @@ func runList(ctx context.Context, dockerCLI command.Cli, options listOptions) er
|
|||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
|
|
||||||
listOpts := types.ServiceListOptions{
|
listOpts := swarm.ServiceListOptions{
|
||||||
Filters: options.filter.Value(),
|
Filters: options.filter.Value(),
|
||||||
// When not running "quiet", also get service status (number of running
|
// 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
|
// and desired tasks). Note that this is only supported on API v1.41 and
|
||||||
@ -147,7 +146,7 @@ func AppendServiceStatus(ctx context.Context, c client.APIClient, services []swa
|
|||||||
return services, nil
|
return services, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks, err := c.TaskList(ctx, types.TaskListOptions{Filters: taskFilter})
|
tasks, err := c.TaskList(ctx, swarm.TaskListOptions{Filters: taskFilter})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -184,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) {
|
func getActiveNodes(ctx context.Context, c client.NodeAPIClient) (map[string]struct{}, error) {
|
||||||
nodes, err := c.NodeList(ctx, types.NodeListOptions{})
|
nodes, err := c.NodeList(ctx, swarm.NodeListOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,6 @@ import (
|
|||||||
|
|
||||||
"github.com/docker/cli/internal/test"
|
"github.com/docker/cli/internal/test"
|
||||||
"github.com/docker/cli/internal/test/builders"
|
"github.com/docker/cli/internal/test/builders"
|
||||||
"github.com/docker/docker/api/types"
|
|
||||||
"github.com/docker/docker/api/types/swarm"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
"github.com/docker/docker/api/types/versions"
|
"github.com/docker/docker/api/types/versions"
|
||||||
"gotest.tools/v3/assert"
|
"gotest.tools/v3/assert"
|
||||||
@ -19,7 +18,7 @@ import (
|
|||||||
|
|
||||||
func TestServiceListOrder(t *testing.T) {
|
func TestServiceListOrder(t *testing.T) {
|
||||||
cli := test.NewFakeCli(&fakeClient{
|
cli := test.NewFakeCli(&fakeClient{
|
||||||
serviceListFunc: func(ctx context.Context, options types.ServiceListOptions) ([]swarm.Service, error) {
|
serviceListFunc: func(ctx context.Context, options swarm.ServiceListOptions) ([]swarm.Service, error) {
|
||||||
return []swarm.Service{
|
return []swarm.Service{
|
||||||
newService("a57dbe8", "service-1-foo"),
|
newService("a57dbe8", "service-1-foo"),
|
||||||
newService("a57dbdd", "service-10-foo"),
|
newService("a57dbdd", "service-10-foo"),
|
||||||
@ -173,7 +172,7 @@ func TestServiceListServiceStatus(t *testing.T) {
|
|||||||
tc.cluster = generateCluster(t, tc.opts)
|
tc.cluster = generateCluster(t, tc.opts)
|
||||||
}
|
}
|
||||||
cli := test.NewFakeCli(&fakeClient{
|
cli := test.NewFakeCli(&fakeClient{
|
||||||
serviceListFunc: func(ctx context.Context, options types.ServiceListOptions) ([]swarm.Service, error) {
|
serviceListFunc: func(ctx context.Context, options swarm.ServiceListOptions) ([]swarm.Service, error) {
|
||||||
if !options.Status || versions.LessThan(tc.opts.apiVersion, "1.41") {
|
if !options.Status || versions.LessThan(tc.opts.apiVersion, "1.41") {
|
||||||
// Don't return "ServiceStatus" if not requested, or on older API versions
|
// Don't return "ServiceStatus" if not requested, or on older API versions
|
||||||
for i := range tc.cluster.services {
|
for i := range tc.cluster.services {
|
||||||
@ -182,10 +181,10 @@ func TestServiceListServiceStatus(t *testing.T) {
|
|||||||
}
|
}
|
||||||
return tc.cluster.services, nil
|
return tc.cluster.services, nil
|
||||||
},
|
},
|
||||||
taskListFunc: func(context.Context, types.TaskListOptions) ([]swarm.Task, error) {
|
taskListFunc: func(context.Context, swarm.TaskListOptions) ([]swarm.Task, error) {
|
||||||
return tc.cluster.tasks, nil
|
return tc.cluster.tasks, nil
|
||||||
},
|
},
|
||||||
nodeListFunc: func(ctx context.Context, options types.NodeListOptions) ([]swarm.Node, error) {
|
nodeListFunc: func(ctx context.Context, options swarm.NodeListOptions) ([]swarm.Node, error) {
|
||||||
return tc.cluster.nodes, nil
|
return tc.cluster.nodes, nil
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
@ -15,7 +15,6 @@ import (
|
|||||||
"github.com/docker/cli/cli/command/completion"
|
"github.com/docker/cli/cli/command/completion"
|
||||||
"github.com/docker/cli/cli/command/idresolver"
|
"github.com/docker/cli/cli/command/idresolver"
|
||||||
"github.com/docker/cli/internal/logdetails"
|
"github.com/docker/cli/internal/logdetails"
|
||||||
"github.com/docker/docker/api/types"
|
|
||||||
"github.com/docker/docker/api/types/container"
|
"github.com/docker/docker/api/types/container"
|
||||||
"github.com/docker/docker/api/types/swarm"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
"github.com/docker/docker/client"
|
"github.com/docker/docker/client"
|
||||||
@ -91,7 +90,7 @@ func runLogs(ctx context.Context, dockerCli command.Cli, opts *logsOptions) erro
|
|||||||
logfunc func(context.Context, string, container.LogsOptions) (io.ReadCloser, error)
|
logfunc func(context.Context, string, container.LogsOptions) (io.ReadCloser, error)
|
||||||
)
|
)
|
||||||
|
|
||||||
service, _, err := apiClient.ServiceInspectWithRaw(ctx, opts.target, types.ServiceInspectOptions{})
|
service, _, err := apiClient.ServiceInspectWithRaw(ctx, opts.target, swarm.ServiceInspectOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// if it's any error other than service not found, it's Real
|
// if it's any error other than service not found, it's Real
|
||||||
if !cerrdefs.IsNotFound(err) {
|
if !cerrdefs.IsNotFound(err) {
|
||||||
|
@ -11,7 +11,6 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
|
||||||
"github.com/docker/docker/api/types/filters"
|
"github.com/docker/docker/api/types/filters"
|
||||||
"github.com/docker/docker/api/types/swarm"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
"github.com/docker/docker/client"
|
"github.com/docker/docker/client"
|
||||||
@ -89,7 +88,7 @@ func ServiceProgress(ctx context.Context, apiClient client.APIClient, serviceID
|
|||||||
)
|
)
|
||||||
|
|
||||||
for {
|
for {
|
||||||
service, _, err := apiClient.ServiceInspectWithRaw(ctx, serviceID, types.ServiceInspectOptions{})
|
service, _, err := apiClient.ServiceInspectWithRaw(ctx, serviceID, swarm.ServiceInspectOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -143,7 +142,7 @@ func ServiceProgress(ctx context.Context, apiClient client.APIClient, serviceID
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks, err := apiClient.TaskList(ctx, types.TaskListOptions{Filters: filters.NewArgs(
|
tasks, err := apiClient.TaskList(ctx, swarm.TaskListOptions{Filters: filters.NewArgs(
|
||||||
filters.KeyValuePair{Key: "service", Value: service.ID},
|
filters.KeyValuePair{Key: "service", Value: service.ID},
|
||||||
filters.KeyValuePair{Key: "_up-to-date", Value: "true"},
|
filters.KeyValuePair{Key: "_up-to-date", Value: "true"},
|
||||||
)})
|
)})
|
||||||
@ -217,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.
|
// 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) {
|
func getActiveNodes(ctx context.Context, apiClient client.NodeAPIClient) (map[string]struct{}, error) {
|
||||||
nodes, err := apiClient.NodeList(ctx, types.NodeListOptions{})
|
nodes, err := apiClient.NodeList(ctx, swarm.NodeListOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -11,8 +11,8 @@ import (
|
|||||||
"github.com/docker/cli/cli/command/node"
|
"github.com/docker/cli/cli/command/node"
|
||||||
"github.com/docker/cli/cli/command/task"
|
"github.com/docker/cli/cli/command/task"
|
||||||
"github.com/docker/cli/opts"
|
"github.com/docker/cli/opts"
|
||||||
"github.com/docker/docker/api/types"
|
|
||||||
"github.com/docker/docker/api/types/filters"
|
"github.com/docker/docker/api/types/filters"
|
||||||
|
"github.com/docker/docker/api/types/swarm"
|
||||||
"github.com/docker/docker/client"
|
"github.com/docker/docker/client"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
@ -68,7 +68,7 @@ func runPS(ctx context.Context, dockerCli command.Cli, options psOptions) error
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks, err := apiClient.TaskList(ctx, types.TaskListOptions{Filters: filter})
|
tasks, err := apiClient.TaskList(ctx, swarm.TaskListOptions{Filters: filter})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -98,11 +98,11 @@ func createFilter(ctx context.Context, apiClient client.APIClient, options psOpt
|
|||||||
serviceIDFilter.Add("id", service)
|
serviceIDFilter.Add("id", service)
|
||||||
serviceNameFilter.Add("name", service)
|
serviceNameFilter.Add("name", service)
|
||||||
}
|
}
|
||||||
serviceByIDList, err := apiClient.ServiceList(ctx, types.ServiceListOptions{Filters: serviceIDFilter})
|
serviceByIDList, err := apiClient.ServiceList(ctx, swarm.ServiceListOptions{Filters: serviceIDFilter})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return filter, nil, err
|
return filter, nil, err
|
||||||
}
|
}
|
||||||
serviceByNameList, err := apiClient.ServiceList(ctx, types.ServiceListOptions{Filters: serviceNameFilter})
|
serviceByNameList, err := apiClient.ServiceList(ctx, swarm.ServiceListOptions{Filters: serviceNameFilter})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return filter, nil, err
|
return filter, nil, err
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,6 @@ import (
|
|||||||
|
|
||||||
"github.com/docker/cli/internal/test"
|
"github.com/docker/cli/internal/test"
|
||||||
"github.com/docker/cli/opts"
|
"github.com/docker/cli/opts"
|
||||||
"github.com/docker/docker/api/types"
|
|
||||||
"github.com/docker/docker/api/types/filters"
|
"github.com/docker/docker/api/types/filters"
|
||||||
"github.com/docker/docker/api/types/swarm"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
"github.com/docker/docker/api/types/system"
|
"github.com/docker/docker/api/types/system"
|
||||||
@ -17,7 +16,7 @@ import (
|
|||||||
|
|
||||||
func TestCreateFilter(t *testing.T) {
|
func TestCreateFilter(t *testing.T) {
|
||||||
client := &fakeClient{
|
client := &fakeClient{
|
||||||
serviceListFunc: func(ctx context.Context, options types.ServiceListOptions) ([]swarm.Service, error) {
|
serviceListFunc: func(ctx context.Context, options swarm.ServiceListOptions) ([]swarm.Service, error) {
|
||||||
return []swarm.Service{
|
return []swarm.Service{
|
||||||
{ID: "idmatch"},
|
{ID: "idmatch"},
|
||||||
{ID: "idprefixmatch"},
|
{ID: "idprefixmatch"},
|
||||||
@ -49,7 +48,7 @@ func TestCreateFilter(t *testing.T) {
|
|||||||
|
|
||||||
func TestCreateFilterWithAmbiguousIDPrefixError(t *testing.T) {
|
func TestCreateFilterWithAmbiguousIDPrefixError(t *testing.T) {
|
||||||
client := &fakeClient{
|
client := &fakeClient{
|
||||||
serviceListFunc: func(ctx context.Context, options types.ServiceListOptions) ([]swarm.Service, error) {
|
serviceListFunc: func(ctx context.Context, options swarm.ServiceListOptions) ([]swarm.Service, error) {
|
||||||
return []swarm.Service{
|
return []swarm.Service{
|
||||||
{ID: "aaaone"},
|
{ID: "aaaone"},
|
||||||
{ID: "aaatwo"},
|
{ID: "aaatwo"},
|
||||||
@ -76,7 +75,7 @@ func TestCreateFilterNoneFound(t *testing.T) {
|
|||||||
|
|
||||||
func TestRunPSWarnsOnNotFound(t *testing.T) {
|
func TestRunPSWarnsOnNotFound(t *testing.T) {
|
||||||
client := &fakeClient{
|
client := &fakeClient{
|
||||||
serviceListFunc: func(ctx context.Context, options types.ServiceListOptions) ([]swarm.Service, error) {
|
serviceListFunc: func(ctx context.Context, options swarm.ServiceListOptions) ([]swarm.Service, error) {
|
||||||
return []swarm.Service{
|
return []swarm.Service{
|
||||||
{ID: "foo"},
|
{ID: "foo"},
|
||||||
}, nil
|
}, nil
|
||||||
@ -97,10 +96,10 @@ func TestRunPSWarnsOnNotFound(t *testing.T) {
|
|||||||
|
|
||||||
func TestRunPSQuiet(t *testing.T) {
|
func TestRunPSQuiet(t *testing.T) {
|
||||||
client := &fakeClient{
|
client := &fakeClient{
|
||||||
serviceListFunc: func(ctx context.Context, options types.ServiceListOptions) ([]swarm.Service, error) {
|
serviceListFunc: func(ctx context.Context, options swarm.ServiceListOptions) ([]swarm.Service, error) {
|
||||||
return []swarm.Service{{ID: "foo"}}, nil
|
return []swarm.Service{{ID: "foo"}}, nil
|
||||||
},
|
},
|
||||||
taskListFunc: func(ctx context.Context, options types.TaskListOptions) ([]swarm.Task, error) {
|
taskListFunc: func(ctx context.Context, options swarm.TaskListOptions) ([]swarm.Task, error) {
|
||||||
return []swarm.Task{{ID: "sxabyp0obqokwekpun4rjo0b3"}}, nil
|
return []swarm.Task{{ID: "sxabyp0obqokwekpun4rjo0b3"}}, nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ import (
|
|||||||
"github.com/docker/cli/cli"
|
"github.com/docker/cli/cli"
|
||||||
"github.com/docker/cli/cli/command"
|
"github.com/docker/cli/cli/command"
|
||||||
"github.com/docker/cli/cli/command/completion"
|
"github.com/docker/cli/cli/command/completion"
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
"github.com/docker/docker/api/types/versions"
|
"github.com/docker/docker/api/types/versions"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"github.com/spf13/pflag"
|
"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 {
|
func runRollback(ctx context.Context, dockerCLI command.Cli, options *serviceOptions, serviceID string) error {
|
||||||
apiClient := dockerCLI.Client()
|
apiClient := dockerCLI.Client()
|
||||||
|
|
||||||
service, _, err := apiClient.ServiceInspectWithRaw(ctx, serviceID, types.ServiceInspectOptions{})
|
service, _, err := apiClient.ServiceInspectWithRaw(ctx, serviceID, swarm.ServiceInspectOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
response, err := apiClient.ServiceUpdate(ctx, service.ID, service.Version, service.Spec, types.ServiceUpdateOptions{
|
response, err := apiClient.ServiceUpdate(ctx, service.ID, service.Version, service.Spec, swarm.ServiceUpdateOptions{
|
||||||
Rollback: "previous", // TODO(thaJeztah): this should have a const defined
|
Rollback: "previous", // TODO(thaJeztah): this should have a const defined
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -8,7 +8,6 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/docker/cli/internal/test"
|
"github.com/docker/cli/internal/test"
|
||||||
"github.com/docker/docker/api/types"
|
|
||||||
"github.com/docker/docker/api/types/swarm"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
"gotest.tools/v3/assert"
|
"gotest.tools/v3/assert"
|
||||||
is "gotest.tools/v3/assert/cmp"
|
is "gotest.tools/v3/assert/cmp"
|
||||||
@ -18,7 +17,7 @@ func TestRollback(t *testing.T) {
|
|||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
name string
|
name string
|
||||||
args []string
|
args []string
|
||||||
serviceUpdateFunc func(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options types.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error)
|
serviceUpdateFunc func(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options swarm.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error)
|
||||||
expectedDockerCliErr string
|
expectedDockerCliErr string
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
@ -28,7 +27,7 @@ func TestRollback(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "rollback-service-with-warnings",
|
name: "rollback-service-with-warnings",
|
||||||
args: []string{"service-id"},
|
args: []string{"service-id"},
|
||||||
serviceUpdateFunc: func(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options types.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error) {
|
serviceUpdateFunc: func(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options swarm.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error) {
|
||||||
response := swarm.ServiceUpdateResponse{}
|
response := swarm.ServiceUpdateResponse{}
|
||||||
|
|
||||||
response.Warnings = []string{
|
response.Warnings = []string{
|
||||||
@ -59,8 +58,8 @@ func TestRollbackWithErrors(t *testing.T) {
|
|||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
name string
|
name string
|
||||||
args []string
|
args []string
|
||||||
serviceInspectWithRawFunc func(ctx context.Context, serviceID string, options types.ServiceInspectOptions) (swarm.Service, []byte, error)
|
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 types.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error)
|
serviceUpdateFunc func(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options swarm.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error)
|
||||||
expectedError string
|
expectedError string
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
@ -75,7 +74,7 @@ func TestRollbackWithErrors(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "service-does-not-exists",
|
name: "service-does-not-exists",
|
||||||
args: []string{"service-id"},
|
args: []string{"service-id"},
|
||||||
serviceInspectWithRawFunc: func(ctx context.Context, serviceID string, options types.ServiceInspectOptions) (swarm.Service, []byte, error) {
|
serviceInspectWithRawFunc: func(ctx context.Context, serviceID string, options swarm.ServiceInspectOptions) (swarm.Service, []byte, error) {
|
||||||
return swarm.Service{}, []byte{}, fmt.Errorf("no such services: %s", serviceID)
|
return swarm.Service{}, []byte{}, fmt.Errorf("no such services: %s", serviceID)
|
||||||
},
|
},
|
||||||
expectedError: "no such services: service-id",
|
expectedError: "no such services: service-id",
|
||||||
@ -83,7 +82,7 @@ func TestRollbackWithErrors(t *testing.T) {
|
|||||||
{
|
{
|
||||||
name: "service-update-failed",
|
name: "service-update-failed",
|
||||||
args: []string{"service-id"},
|
args: []string{"service-id"},
|
||||||
serviceUpdateFunc: func(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options types.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error) {
|
serviceUpdateFunc: func(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options swarm.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error) {
|
||||||
return swarm.ServiceUpdateResponse{}, fmt.Errorf("no such services: %s", serviceID)
|
return swarm.ServiceUpdateResponse{}, fmt.Errorf("no such services: %s", serviceID)
|
||||||
},
|
},
|
||||||
expectedError: "no such services: service-id",
|
expectedError: "no such services: service-id",
|
||||||
|
@ -9,7 +9,7 @@ import (
|
|||||||
|
|
||||||
"github.com/docker/cli/cli"
|
"github.com/docker/cli/cli"
|
||||||
"github.com/docker/cli/cli/command"
|
"github.com/docker/cli/cli/command"
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
"github.com/docker/docker/api/types/versions"
|
"github.com/docker/docker/api/types/versions"
|
||||||
"github.com/docker/docker/client"
|
"github.com/docker/docker/client"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
@ -94,7 +94,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) {
|
func runServiceScale(ctx context.Context, apiClient client.ServiceAPIClient, serviceID string, scale uint64) (warnings []string, _ error) {
|
||||||
service, _, err := apiClient.ServiceInspectWithRaw(ctx, serviceID, types.ServiceInspectOptions{})
|
service, _, err := apiClient.ServiceInspectWithRaw(ctx, serviceID, swarm.ServiceInspectOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -109,7 +109,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")
|
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, types.ServiceUpdateOptions{})
|
response, err := apiClient.ServiceUpdate(ctx, service.ID, service.Version, service.Spec, swarm.ServiceUpdateOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,6 @@ import (
|
|||||||
"github.com/docker/cli/cli/command/completion"
|
"github.com/docker/cli/cli/command/completion"
|
||||||
"github.com/docker/cli/opts"
|
"github.com/docker/cli/opts"
|
||||||
"github.com/docker/cli/opts/swarmopts"
|
"github.com/docker/cli/opts/swarmopts"
|
||||||
"github.com/docker/docker/api/types"
|
|
||||||
"github.com/docker/docker/api/types/container"
|
"github.com/docker/docker/api/types/container"
|
||||||
mounttypes "github.com/docker/docker/api/types/mount"
|
mounttypes "github.com/docker/docker/api/types/mount"
|
||||||
"github.com/docker/docker/api/types/network"
|
"github.com/docker/docker/api/types/network"
|
||||||
@ -156,7 +155,7 @@ func newListOptsVarWithValidator(validator opts.ValidatorFctType) *opts.ListOpts
|
|||||||
func runUpdate(ctx context.Context, dockerCLI command.Cli, flags *pflag.FlagSet, options *serviceOptions, serviceID string) error {
|
func runUpdate(ctx context.Context, dockerCLI command.Cli, flags *pflag.FlagSet, options *serviceOptions, serviceID string) error {
|
||||||
apiClient := dockerCLI.Client()
|
apiClient := dockerCLI.Client()
|
||||||
|
|
||||||
service, _, err := apiClient.ServiceInspectWithRaw(ctx, serviceID, types.ServiceInspectOptions{})
|
service, _, err := apiClient.ServiceInspectWithRaw(ctx, serviceID, swarm.ServiceInspectOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -201,7 +200,7 @@ func runUpdate(ctx context.Context, dockerCLI command.Cli, flags *pflag.FlagSet,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updateOpts := types.ServiceUpdateOptions{}
|
updateOpts := swarm.ServiceUpdateOptions{}
|
||||||
if serverSideRollback {
|
if serverSideRollback {
|
||||||
updateOpts.Rollback = "previous"
|
updateOpts.Rollback = "previous"
|
||||||
}
|
}
|
||||||
@ -255,9 +254,9 @@ func runUpdate(ctx context.Context, dockerCLI command.Cli, flags *pflag.FlagSet,
|
|||||||
}
|
}
|
||||||
updateOpts.EncodedRegistryAuth = encodedAuth
|
updateOpts.EncodedRegistryAuth = encodedAuth
|
||||||
case clientSideRollback:
|
case clientSideRollback:
|
||||||
updateOpts.RegistryAuthFrom = types.RegistryAuthFromPreviousSpec
|
updateOpts.RegistryAuthFrom = swarm.RegistryAuthFromPreviousSpec
|
||||||
default:
|
default:
|
||||||
updateOpts.RegistryAuthFrom = types.RegistryAuthFromSpec
|
updateOpts.RegistryAuthFrom = swarm.RegistryAuthFromSpec
|
||||||
}
|
}
|
||||||
|
|
||||||
response, err := apiClient.ServiceUpdate(ctx, service.ID, service.Version, *spec, updateOpts)
|
response, err := apiClient.ServiceUpdate(ctx, service.ID, service.Version, *spec, updateOpts)
|
||||||
|
@ -28,15 +28,15 @@ type fakeClient struct {
|
|||||||
removedSecrets []string
|
removedSecrets []string
|
||||||
removedConfigs []string
|
removedConfigs []string
|
||||||
|
|
||||||
serviceListFunc func(options types.ServiceListOptions) ([]swarm.Service, error)
|
serviceListFunc func(options swarm.ServiceListOptions) ([]swarm.Service, error)
|
||||||
networkListFunc func(options network.ListOptions) ([]network.Summary, error)
|
networkListFunc func(options network.ListOptions) ([]network.Summary, error)
|
||||||
secretListFunc func(options swarm.SecretListOptions) ([]swarm.Secret, error)
|
secretListFunc func(options swarm.SecretListOptions) ([]swarm.Secret, error)
|
||||||
configListFunc func(options swarm.ConfigListOptions) ([]swarm.Config, error)
|
configListFunc func(options swarm.ConfigListOptions) ([]swarm.Config, error)
|
||||||
nodeListFunc func(options types.NodeListOptions) ([]swarm.Node, error)
|
nodeListFunc func(options swarm.NodeListOptions) ([]swarm.Node, error)
|
||||||
taskListFunc func(options types.TaskListOptions) ([]swarm.Task, error)
|
taskListFunc func(options swarm.TaskListOptions) ([]swarm.Task, error)
|
||||||
nodeInspectWithRaw func(ref string) (swarm.Node, []byte, error)
|
nodeInspectWithRaw func(ref string) (swarm.Node, []byte, error)
|
||||||
|
|
||||||
serviceUpdateFunc func(serviceID string, version swarm.Version, service swarm.ServiceSpec, options types.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error)
|
serviceUpdateFunc func(serviceID string, version swarm.Version, service swarm.ServiceSpec, options swarm.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error)
|
||||||
|
|
||||||
serviceRemoveFunc func(serviceID string) error
|
serviceRemoveFunc func(serviceID string) error
|
||||||
networkRemoveFunc func(networkID string) error
|
networkRemoveFunc func(networkID string) error
|
||||||
@ -55,7 +55,7 @@ func (cli *fakeClient) ClientVersion() string {
|
|||||||
return cli.version
|
return cli.version
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cli *fakeClient) ServiceList(_ context.Context, options types.ServiceListOptions) ([]swarm.Service, error) {
|
func (cli *fakeClient) ServiceList(_ context.Context, options swarm.ServiceListOptions) ([]swarm.Service, error) {
|
||||||
if cli.serviceListFunc != nil {
|
if cli.serviceListFunc != nil {
|
||||||
return cli.serviceListFunc(options)
|
return cli.serviceListFunc(options)
|
||||||
}
|
}
|
||||||
@ -115,14 +115,14 @@ func (cli *fakeClient) ConfigList(_ context.Context, options swarm.ConfigListOpt
|
|||||||
return configsList, nil
|
return configsList, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cli *fakeClient) TaskList(_ context.Context, options types.TaskListOptions) ([]swarm.Task, error) {
|
func (cli *fakeClient) TaskList(_ context.Context, options swarm.TaskListOptions) ([]swarm.Task, error) {
|
||||||
if cli.taskListFunc != nil {
|
if cli.taskListFunc != nil {
|
||||||
return cli.taskListFunc(options)
|
return cli.taskListFunc(options)
|
||||||
}
|
}
|
||||||
return []swarm.Task{}, nil
|
return []swarm.Task{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cli *fakeClient) NodeList(_ context.Context, options types.NodeListOptions) ([]swarm.Node, error) {
|
func (cli *fakeClient) NodeList(_ context.Context, options swarm.NodeListOptions) ([]swarm.Node, error) {
|
||||||
if cli.nodeListFunc != nil {
|
if cli.nodeListFunc != nil {
|
||||||
return cli.nodeListFunc(options)
|
return cli.nodeListFunc(options)
|
||||||
}
|
}
|
||||||
@ -136,7 +136,7 @@ func (cli *fakeClient) NodeInspectWithRaw(_ context.Context, ref string) (swarm.
|
|||||||
return swarm.Node{}, nil, nil
|
return swarm.Node{}, nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cli *fakeClient) ServiceUpdate(_ context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options types.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error) {
|
func (cli *fakeClient) ServiceUpdate(_ context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options swarm.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error) {
|
||||||
if cli.serviceUpdateFunc != nil {
|
if cli.serviceUpdateFunc != nil {
|
||||||
return cli.serviceUpdateFunc(serviceID, version, service, options)
|
return cli.serviceUpdateFunc(serviceID, version, service, options)
|
||||||
}
|
}
|
||||||
@ -180,7 +180,7 @@ func (cli *fakeClient) ConfigRemove(_ context.Context, configID string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*fakeClient) ServiceInspectWithRaw(_ context.Context, serviceID string, _ types.ServiceInspectOptions) (swarm.Service, []byte, error) {
|
func (*fakeClient) ServiceInspectWithRaw(_ context.Context, serviceID string, _ swarm.ServiceInspectOptions) (swarm.Service, []byte, error) {
|
||||||
return swarm.Service{
|
return swarm.Service{
|
||||||
ID: serviceID,
|
ID: serviceID,
|
||||||
Spec: swarm.ServiceSpec{
|
Spec: swarm.ServiceSpec{
|
||||||
|
@ -7,7 +7,6 @@ import (
|
|||||||
|
|
||||||
"github.com/docker/cli/internal/test"
|
"github.com/docker/cli/internal/test"
|
||||||
"github.com/docker/cli/internal/test/builders"
|
"github.com/docker/cli/internal/test/builders"
|
||||||
"github.com/docker/docker/api/types"
|
|
||||||
"github.com/docker/docker/api/types/swarm"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
"gotest.tools/v3/assert"
|
"gotest.tools/v3/assert"
|
||||||
"gotest.tools/v3/golden"
|
"gotest.tools/v3/golden"
|
||||||
@ -17,7 +16,7 @@ func TestListErrors(t *testing.T) {
|
|||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
args []string
|
args []string
|
||||||
flags map[string]string
|
flags map[string]string
|
||||||
serviceListFunc func(options types.ServiceListOptions) ([]swarm.Service, error)
|
serviceListFunc func(options swarm.ServiceListOptions) ([]swarm.Service, error)
|
||||||
expectedError string
|
expectedError string
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
@ -33,14 +32,14 @@ func TestListErrors(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
args: []string{},
|
args: []string{},
|
||||||
serviceListFunc: func(options types.ServiceListOptions) ([]swarm.Service, error) {
|
serviceListFunc: func(options swarm.ServiceListOptions) ([]swarm.Service, error) {
|
||||||
return []swarm.Service{}, errors.New("error getting services")
|
return []swarm.Service{}, errors.New("error getting services")
|
||||||
},
|
},
|
||||||
expectedError: "error getting services",
|
expectedError: "error getting services",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
args: []string{},
|
args: []string{},
|
||||||
serviceListFunc: func(options types.ServiceListOptions) ([]swarm.Service, error) {
|
serviceListFunc: func(options swarm.ServiceListOptions) ([]swarm.Service, error) {
|
||||||
return []swarm.Service{*builders.Service()}, nil
|
return []swarm.Service{*builders.Service()}, nil
|
||||||
},
|
},
|
||||||
expectedError: "cannot get label",
|
expectedError: "cannot get label",
|
||||||
@ -115,7 +114,7 @@ func TestStackList(t *testing.T) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
cli := test.NewFakeCli(&fakeClient{
|
cli := test.NewFakeCli(&fakeClient{
|
||||||
serviceListFunc: func(options types.ServiceListOptions) ([]swarm.Service, error) {
|
serviceListFunc: func(options swarm.ServiceListOptions) ([]swarm.Service, error) {
|
||||||
return services, nil
|
return services, nil
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
@ -9,7 +9,6 @@ import (
|
|||||||
"github.com/docker/cli/cli/config/configfile"
|
"github.com/docker/cli/cli/config/configfile"
|
||||||
"github.com/docker/cli/internal/test"
|
"github.com/docker/cli/internal/test"
|
||||||
"github.com/docker/cli/internal/test/builders"
|
"github.com/docker/cli/internal/test/builders"
|
||||||
"github.com/docker/docker/api/types"
|
|
||||||
"github.com/docker/docker/api/types/swarm"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
"gotest.tools/v3/assert"
|
"gotest.tools/v3/assert"
|
||||||
is "gotest.tools/v3/assert/cmp"
|
is "gotest.tools/v3/assert/cmp"
|
||||||
@ -19,7 +18,7 @@ import (
|
|||||||
func TestStackPsErrors(t *testing.T) {
|
func TestStackPsErrors(t *testing.T) {
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
args []string
|
args []string
|
||||||
taskListFunc func(options types.TaskListOptions) ([]swarm.Task, error)
|
taskListFunc func(options swarm.TaskListOptions) ([]swarm.Task, error)
|
||||||
expectedError string
|
expectedError string
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
@ -32,7 +31,7 @@ func TestStackPsErrors(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
args: []string{"foo"},
|
args: []string{"foo"},
|
||||||
taskListFunc: func(options types.TaskListOptions) ([]swarm.Task, error) {
|
taskListFunc: func(options swarm.TaskListOptions) ([]swarm.Task, error) {
|
||||||
return nil, errors.New("error getting tasks")
|
return nil, errors.New("error getting tasks")
|
||||||
},
|
},
|
||||||
expectedError: "error getting tasks",
|
expectedError: "error getting tasks",
|
||||||
@ -55,7 +54,7 @@ func TestStackPsErrors(t *testing.T) {
|
|||||||
func TestStackPs(t *testing.T) {
|
func TestStackPs(t *testing.T) {
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
doc string
|
doc string
|
||||||
taskListFunc func(types.TaskListOptions) ([]swarm.Task, error)
|
taskListFunc func(swarm.TaskListOptions) ([]swarm.Task, error)
|
||||||
nodeInspectWithRaw func(string) (swarm.Node, []byte, error)
|
nodeInspectWithRaw func(string) (swarm.Node, []byte, error)
|
||||||
config configfile.ConfigFile
|
config configfile.ConfigFile
|
||||||
args []string
|
args []string
|
||||||
@ -70,7 +69,7 @@ func TestStackPs(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
doc: "WithEmptyStack",
|
doc: "WithEmptyStack",
|
||||||
taskListFunc: func(options types.TaskListOptions) ([]swarm.Task, error) {
|
taskListFunc: func(options swarm.TaskListOptions) ([]swarm.Task, error) {
|
||||||
return []swarm.Task{}, nil
|
return []swarm.Task{}, nil
|
||||||
},
|
},
|
||||||
args: []string{"foo"},
|
args: []string{"foo"},
|
||||||
@ -78,7 +77,7 @@ func TestStackPs(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
doc: "WithQuietOption",
|
doc: "WithQuietOption",
|
||||||
taskListFunc: func(options types.TaskListOptions) ([]swarm.Task, error) {
|
taskListFunc: func(options swarm.TaskListOptions) ([]swarm.Task, error) {
|
||||||
return []swarm.Task{*builders.Task(builders.TaskID("id-foo"))}, nil
|
return []swarm.Task{*builders.Task(builders.TaskID("id-foo"))}, nil
|
||||||
},
|
},
|
||||||
args: []string{"foo"},
|
args: []string{"foo"},
|
||||||
@ -89,7 +88,7 @@ func TestStackPs(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
doc: "WithNoTruncOption",
|
doc: "WithNoTruncOption",
|
||||||
taskListFunc: func(options types.TaskListOptions) ([]swarm.Task, error) {
|
taskListFunc: func(options swarm.TaskListOptions) ([]swarm.Task, error) {
|
||||||
return []swarm.Task{*builders.Task(builders.TaskID("xn4cypcov06f2w8gsbaf2lst3"))}, nil
|
return []swarm.Task{*builders.Task(builders.TaskID("xn4cypcov06f2w8gsbaf2lst3"))}, nil
|
||||||
},
|
},
|
||||||
args: []string{"foo"},
|
args: []string{"foo"},
|
||||||
@ -101,7 +100,7 @@ func TestStackPs(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
doc: "WithNoResolveOption",
|
doc: "WithNoResolveOption",
|
||||||
taskListFunc: func(options types.TaskListOptions) ([]swarm.Task, error) {
|
taskListFunc: func(options swarm.TaskListOptions) ([]swarm.Task, error) {
|
||||||
return []swarm.Task{*builders.Task(
|
return []swarm.Task{*builders.Task(
|
||||||
builders.TaskNodeID("id-node-foo"),
|
builders.TaskNodeID("id-node-foo"),
|
||||||
)}, nil
|
)}, nil
|
||||||
@ -118,7 +117,7 @@ func TestStackPs(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
doc: "WithFormat",
|
doc: "WithFormat",
|
||||||
taskListFunc: func(options types.TaskListOptions) ([]swarm.Task, error) {
|
taskListFunc: func(options swarm.TaskListOptions) ([]swarm.Task, error) {
|
||||||
return []swarm.Task{*builders.Task(builders.TaskServiceID("service-id-foo"))}, nil
|
return []swarm.Task{*builders.Task(builders.TaskServiceID("service-id-foo"))}, nil
|
||||||
},
|
},
|
||||||
args: []string{"foo"},
|
args: []string{"foo"},
|
||||||
@ -129,7 +128,7 @@ func TestStackPs(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
doc: "WithConfigFormat",
|
doc: "WithConfigFormat",
|
||||||
taskListFunc: func(options types.TaskListOptions) ([]swarm.Task, error) {
|
taskListFunc: func(options swarm.TaskListOptions) ([]swarm.Task, error) {
|
||||||
return []swarm.Task{*builders.Task(builders.TaskServiceID("service-id-foo"))}, nil
|
return []swarm.Task{*builders.Task(builders.TaskServiceID("service-id-foo"))}, nil
|
||||||
},
|
},
|
||||||
config: configfile.ConfigFile{
|
config: configfile.ConfigFile{
|
||||||
@ -140,7 +139,7 @@ func TestStackPs(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
doc: "WithoutFormat",
|
doc: "WithoutFormat",
|
||||||
taskListFunc: func(options types.TaskListOptions) ([]swarm.Task, error) {
|
taskListFunc: func(options swarm.TaskListOptions) ([]swarm.Task, error) {
|
||||||
return []swarm.Task{*builders.Task(
|
return []swarm.Task{*builders.Task(
|
||||||
builders.TaskID("id-foo"),
|
builders.TaskID("id-foo"),
|
||||||
builders.TaskServiceID("service-id-foo"),
|
builders.TaskServiceID("service-id-foo"),
|
||||||
|
@ -8,7 +8,6 @@ import (
|
|||||||
"github.com/docker/cli/cli/config/configfile"
|
"github.com/docker/cli/cli/config/configfile"
|
||||||
"github.com/docker/cli/internal/test"
|
"github.com/docker/cli/internal/test"
|
||||||
"github.com/docker/cli/internal/test/builders"
|
"github.com/docker/cli/internal/test/builders"
|
||||||
"github.com/docker/docker/api/types"
|
|
||||||
"github.com/docker/docker/api/types/swarm"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
"gotest.tools/v3/assert"
|
"gotest.tools/v3/assert"
|
||||||
is "gotest.tools/v3/assert/cmp"
|
is "gotest.tools/v3/assert/cmp"
|
||||||
@ -19,37 +18,37 @@ func TestStackServicesErrors(t *testing.T) {
|
|||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
args []string
|
args []string
|
||||||
flags map[string]string
|
flags map[string]string
|
||||||
serviceListFunc func(options types.ServiceListOptions) ([]swarm.Service, error)
|
serviceListFunc func(options swarm.ServiceListOptions) ([]swarm.Service, error)
|
||||||
nodeListFunc func(options types.NodeListOptions) ([]swarm.Node, error)
|
nodeListFunc func(options swarm.NodeListOptions) ([]swarm.Node, error)
|
||||||
taskListFunc func(options types.TaskListOptions) ([]swarm.Task, error)
|
taskListFunc func(options swarm.TaskListOptions) ([]swarm.Task, error)
|
||||||
expectedError string
|
expectedError string
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
args: []string{"foo"},
|
args: []string{"foo"},
|
||||||
serviceListFunc: func(options types.ServiceListOptions) ([]swarm.Service, error) {
|
serviceListFunc: func(options swarm.ServiceListOptions) ([]swarm.Service, error) {
|
||||||
return nil, errors.New("error getting services")
|
return nil, errors.New("error getting services")
|
||||||
},
|
},
|
||||||
expectedError: "error getting services",
|
expectedError: "error getting services",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
args: []string{"foo"},
|
args: []string{"foo"},
|
||||||
serviceListFunc: func(options types.ServiceListOptions) ([]swarm.Service, error) {
|
serviceListFunc: func(options swarm.ServiceListOptions) ([]swarm.Service, error) {
|
||||||
return []swarm.Service{*builders.Service(builders.GlobalService())}, nil
|
return []swarm.Service{*builders.Service(builders.GlobalService())}, nil
|
||||||
},
|
},
|
||||||
nodeListFunc: func(options types.NodeListOptions) ([]swarm.Node, error) {
|
nodeListFunc: func(options swarm.NodeListOptions) ([]swarm.Node, error) {
|
||||||
return nil, errors.New("error getting nodes")
|
return nil, errors.New("error getting nodes")
|
||||||
},
|
},
|
||||||
taskListFunc: func(options types.TaskListOptions) ([]swarm.Task, error) {
|
taskListFunc: func(options swarm.TaskListOptions) ([]swarm.Task, error) {
|
||||||
return []swarm.Task{*builders.Task()}, nil
|
return []swarm.Task{*builders.Task()}, nil
|
||||||
},
|
},
|
||||||
expectedError: "error getting nodes",
|
expectedError: "error getting nodes",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
args: []string{"foo"},
|
args: []string{"foo"},
|
||||||
serviceListFunc: func(options types.ServiceListOptions) ([]swarm.Service, error) {
|
serviceListFunc: func(options swarm.ServiceListOptions) ([]swarm.Service, error) {
|
||||||
return []swarm.Service{*builders.Service(builders.GlobalService())}, nil
|
return []swarm.Service{*builders.Service(builders.GlobalService())}, nil
|
||||||
},
|
},
|
||||||
taskListFunc: func(options types.TaskListOptions) ([]swarm.Task, error) {
|
taskListFunc: func(options swarm.TaskListOptions) ([]swarm.Task, error) {
|
||||||
return nil, errors.New("error getting tasks")
|
return nil, errors.New("error getting tasks")
|
||||||
},
|
},
|
||||||
expectedError: "error getting tasks",
|
expectedError: "error getting tasks",
|
||||||
@ -59,7 +58,7 @@ func TestStackServicesErrors(t *testing.T) {
|
|||||||
flags: map[string]string{
|
flags: map[string]string{
|
||||||
"format": "{{invalid format}}",
|
"format": "{{invalid format}}",
|
||||||
},
|
},
|
||||||
serviceListFunc: func(options types.ServiceListOptions) ([]swarm.Service, error) {
|
serviceListFunc: func(options swarm.ServiceListOptions) ([]swarm.Service, error) {
|
||||||
return []swarm.Service{*builders.Service()}, nil
|
return []swarm.Service{*builders.Service()}, nil
|
||||||
},
|
},
|
||||||
expectedError: "template parsing error",
|
expectedError: "template parsing error",
|
||||||
@ -96,7 +95,7 @@ func TestRunServicesWithEmptyName(t *testing.T) {
|
|||||||
|
|
||||||
func TestStackServicesEmptyServiceList(t *testing.T) {
|
func TestStackServicesEmptyServiceList(t *testing.T) {
|
||||||
fakeCli := test.NewFakeCli(&fakeClient{
|
fakeCli := test.NewFakeCli(&fakeClient{
|
||||||
serviceListFunc: func(options types.ServiceListOptions) ([]swarm.Service, error) {
|
serviceListFunc: func(options swarm.ServiceListOptions) ([]swarm.Service, error) {
|
||||||
return []swarm.Service{}, nil
|
return []swarm.Service{}, nil
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@ -109,7 +108,7 @@ func TestStackServicesEmptyServiceList(t *testing.T) {
|
|||||||
|
|
||||||
func TestStackServicesWithQuietOption(t *testing.T) {
|
func TestStackServicesWithQuietOption(t *testing.T) {
|
||||||
cli := test.NewFakeCli(&fakeClient{
|
cli := test.NewFakeCli(&fakeClient{
|
||||||
serviceListFunc: func(options types.ServiceListOptions) ([]swarm.Service, error) {
|
serviceListFunc: func(options swarm.ServiceListOptions) ([]swarm.Service, error) {
|
||||||
return []swarm.Service{*builders.Service(builders.ServiceID("id-foo"))}, nil
|
return []swarm.Service{*builders.Service(builders.ServiceID("id-foo"))}, nil
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
@ -122,7 +121,7 @@ func TestStackServicesWithQuietOption(t *testing.T) {
|
|||||||
|
|
||||||
func TestStackServicesWithFormat(t *testing.T) {
|
func TestStackServicesWithFormat(t *testing.T) {
|
||||||
cli := test.NewFakeCli(&fakeClient{
|
cli := test.NewFakeCli(&fakeClient{
|
||||||
serviceListFunc: func(options types.ServiceListOptions) ([]swarm.Service, error) {
|
serviceListFunc: func(options swarm.ServiceListOptions) ([]swarm.Service, error) {
|
||||||
return []swarm.Service{
|
return []swarm.Service{
|
||||||
*builders.Service(builders.ServiceName("service-name-foo")),
|
*builders.Service(builders.ServiceName("service-name-foo")),
|
||||||
}, nil
|
}, nil
|
||||||
@ -137,7 +136,7 @@ func TestStackServicesWithFormat(t *testing.T) {
|
|||||||
|
|
||||||
func TestStackServicesWithConfigFormat(t *testing.T) {
|
func TestStackServicesWithConfigFormat(t *testing.T) {
|
||||||
cli := test.NewFakeCli(&fakeClient{
|
cli := test.NewFakeCli(&fakeClient{
|
||||||
serviceListFunc: func(options types.ServiceListOptions) ([]swarm.Service, error) {
|
serviceListFunc: func(options swarm.ServiceListOptions) ([]swarm.Service, error) {
|
||||||
return []swarm.Service{
|
return []swarm.Service{
|
||||||
*builders.Service(builders.ServiceName("service-name-foo")),
|
*builders.Service(builders.ServiceName("service-name-foo")),
|
||||||
}, nil
|
}, nil
|
||||||
@ -154,7 +153,7 @@ func TestStackServicesWithConfigFormat(t *testing.T) {
|
|||||||
|
|
||||||
func TestStackServicesWithoutFormat(t *testing.T) {
|
func TestStackServicesWithoutFormat(t *testing.T) {
|
||||||
cli := test.NewFakeCli(&fakeClient{
|
cli := test.NewFakeCli(&fakeClient{
|
||||||
serviceListFunc: func(options types.ServiceListOptions) ([]swarm.Service, error) {
|
serviceListFunc: func(options swarm.ServiceListOptions) ([]swarm.Service, error) {
|
||||||
return []swarm.Service{*builders.Service(
|
return []swarm.Service{*builders.Service(
|
||||||
builders.ServiceName("name-foo"),
|
builders.ServiceName("name-foo"),
|
||||||
builders.ServiceID("id-foo"),
|
builders.ServiceID("id-foo"),
|
||||||
|
@ -28,15 +28,15 @@ type fakeClient struct {
|
|||||||
removedSecrets []string
|
removedSecrets []string
|
||||||
removedConfigs []string
|
removedConfigs []string
|
||||||
|
|
||||||
serviceListFunc func(options types.ServiceListOptions) ([]swarm.Service, error)
|
serviceListFunc func(options swarm.ServiceListOptions) ([]swarm.Service, error)
|
||||||
networkListFunc func(options network.ListOptions) ([]network.Summary, error)
|
networkListFunc func(options network.ListOptions) ([]network.Summary, error)
|
||||||
secretListFunc func(options swarm.SecretListOptions) ([]swarm.Secret, error)
|
secretListFunc func(options swarm.SecretListOptions) ([]swarm.Secret, error)
|
||||||
configListFunc func(options swarm.ConfigListOptions) ([]swarm.Config, error)
|
configListFunc func(options swarm.ConfigListOptions) ([]swarm.Config, error)
|
||||||
nodeListFunc func(options types.NodeListOptions) ([]swarm.Node, error)
|
nodeListFunc func(options swarm.NodeListOptions) ([]swarm.Node, error)
|
||||||
taskListFunc func(options types.TaskListOptions) ([]swarm.Task, error)
|
taskListFunc func(options swarm.TaskListOptions) ([]swarm.Task, error)
|
||||||
nodeInspectWithRaw func(ref string) (swarm.Node, []byte, error)
|
nodeInspectWithRaw func(ref string) (swarm.Node, []byte, error)
|
||||||
|
|
||||||
serviceUpdateFunc func(serviceID string, version swarm.Version, service swarm.ServiceSpec, options types.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error)
|
serviceUpdateFunc func(serviceID string, version swarm.Version, service swarm.ServiceSpec, options swarm.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error)
|
||||||
|
|
||||||
serviceRemoveFunc func(serviceID string) error
|
serviceRemoveFunc func(serviceID string) error
|
||||||
networkRemoveFunc func(networkID string) error
|
networkRemoveFunc func(networkID string) error
|
||||||
@ -55,7 +55,7 @@ func (cli *fakeClient) ClientVersion() string {
|
|||||||
return cli.version
|
return cli.version
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cli *fakeClient) ServiceList(_ context.Context, options types.ServiceListOptions) ([]swarm.Service, error) {
|
func (cli *fakeClient) ServiceList(_ context.Context, options swarm.ServiceListOptions) ([]swarm.Service, error) {
|
||||||
if cli.serviceListFunc != nil {
|
if cli.serviceListFunc != nil {
|
||||||
return cli.serviceListFunc(options)
|
return cli.serviceListFunc(options)
|
||||||
}
|
}
|
||||||
@ -115,14 +115,14 @@ func (cli *fakeClient) ConfigList(_ context.Context, options swarm.ConfigListOpt
|
|||||||
return configsList, nil
|
return configsList, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cli *fakeClient) TaskList(_ context.Context, options types.TaskListOptions) ([]swarm.Task, error) {
|
func (cli *fakeClient) TaskList(_ context.Context, options swarm.TaskListOptions) ([]swarm.Task, error) {
|
||||||
if cli.taskListFunc != nil {
|
if cli.taskListFunc != nil {
|
||||||
return cli.taskListFunc(options)
|
return cli.taskListFunc(options)
|
||||||
}
|
}
|
||||||
return []swarm.Task{}, nil
|
return []swarm.Task{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cli *fakeClient) NodeList(_ context.Context, options types.NodeListOptions) ([]swarm.Node, error) {
|
func (cli *fakeClient) NodeList(_ context.Context, options swarm.NodeListOptions) ([]swarm.Node, error) {
|
||||||
if cli.nodeListFunc != nil {
|
if cli.nodeListFunc != nil {
|
||||||
return cli.nodeListFunc(options)
|
return cli.nodeListFunc(options)
|
||||||
}
|
}
|
||||||
@ -136,7 +136,7 @@ func (cli *fakeClient) NodeInspectWithRaw(_ context.Context, ref string) (swarm.
|
|||||||
return swarm.Node{}, nil, nil
|
return swarm.Node{}, nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cli *fakeClient) ServiceUpdate(_ context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options types.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error) {
|
func (cli *fakeClient) ServiceUpdate(_ context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options swarm.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error) {
|
||||||
if cli.serviceUpdateFunc != nil {
|
if cli.serviceUpdateFunc != nil {
|
||||||
return cli.serviceUpdateFunc(serviceID, version, service, options)
|
return cli.serviceUpdateFunc(serviceID, version, service, options)
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,6 @@ import (
|
|||||||
|
|
||||||
"github.com/docker/cli/cli/compose/convert"
|
"github.com/docker/cli/cli/compose/convert"
|
||||||
"github.com/docker/cli/opts"
|
"github.com/docker/cli/opts"
|
||||||
"github.com/docker/docker/api/types"
|
|
||||||
"github.com/docker/docker/api/types/filters"
|
"github.com/docker/docker/api/types/filters"
|
||||||
"github.com/docker/docker/api/types/network"
|
"github.com/docker/docker/api/types/network"
|
||||||
"github.com/docker/docker/api/types/swarm"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
@ -31,7 +30,7 @@ func getAllStacksFilter() filters.Args {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getStackServices(ctx context.Context, apiclient client.APIClient, namespace string) ([]swarm.Service, error) {
|
func getStackServices(ctx context.Context, apiclient client.APIClient, namespace string) ([]swarm.Service, error) {
|
||||||
return apiclient.ServiceList(ctx, types.ServiceListOptions{Filters: getStackFilter(namespace)})
|
return apiclient.ServiceList(ctx, swarm.ServiceListOptions{Filters: getStackFilter(namespace)})
|
||||||
}
|
}
|
||||||
|
|
||||||
func getStackNetworks(ctx context.Context, apiclient client.APIClient, namespace string) ([]network.Summary, error) {
|
func getStackNetworks(ctx context.Context, apiclient client.APIClient, namespace string) ([]network.Summary, error) {
|
||||||
@ -47,5 +46,5 @@ func getStackConfigs(ctx context.Context, apiclient client.APIClient, namespace
|
|||||||
}
|
}
|
||||||
|
|
||||||
func getStackTasks(ctx context.Context, apiclient client.APIClient, namespace string) ([]swarm.Task, error) {
|
func getStackTasks(ctx context.Context, apiclient client.APIClient, namespace string) ([]swarm.Task, error) {
|
||||||
return apiclient.TaskList(ctx, types.TaskListOptions{Filters: getStackFilter(namespace)})
|
return apiclient.TaskList(ctx, swarm.TaskListOptions{Filters: getStackFilter(namespace)})
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,6 @@ import (
|
|||||||
"github.com/docker/cli/cli/command/stack/options"
|
"github.com/docker/cli/cli/command/stack/options"
|
||||||
"github.com/docker/cli/cli/compose/convert"
|
"github.com/docker/cli/cli/compose/convert"
|
||||||
composetypes "github.com/docker/cli/cli/compose/types"
|
composetypes "github.com/docker/cli/cli/compose/types"
|
||||||
"github.com/docker/docker/api/types"
|
|
||||||
"github.com/docker/docker/api/types/container"
|
"github.com/docker/docker/api/types/container"
|
||||||
"github.com/docker/docker/api/types/network"
|
"github.com/docker/docker/api/types/network"
|
||||||
"github.com/docker/docker/api/types/swarm"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
@ -221,7 +220,7 @@ func deployServices(ctx context.Context, dockerCLI command.Cli, services map[str
|
|||||||
if service, exists := existingServiceMap[name]; exists {
|
if service, exists := existingServiceMap[name]; exists {
|
||||||
_, _ = fmt.Fprintf(out, "Updating service %s (id: %s)\n", name, service.ID)
|
_, _ = fmt.Fprintf(out, "Updating service %s (id: %s)\n", name, service.ID)
|
||||||
|
|
||||||
updateOpts := types.ServiceUpdateOptions{EncodedRegistryAuth: encodedAuth}
|
updateOpts := swarm.ServiceUpdateOptions{EncodedRegistryAuth: encodedAuth}
|
||||||
|
|
||||||
switch resolveImage {
|
switch resolveImage {
|
||||||
case ResolveImageAlways:
|
case ResolveImageAlways:
|
||||||
@ -266,7 +265,7 @@ func deployServices(ctx context.Context, dockerCLI command.Cli, services map[str
|
|||||||
} else {
|
} else {
|
||||||
_, _ = fmt.Fprintln(out, "Creating service", name)
|
_, _ = fmt.Fprintln(out, "Creating service", name)
|
||||||
|
|
||||||
createOpts := types.ServiceCreateOptions{EncodedRegistryAuth: encodedAuth}
|
createOpts := swarm.ServiceCreateOptions{EncodedRegistryAuth: encodedAuth}
|
||||||
|
|
||||||
// query registry if flag disabling it was not set
|
// query registry if flag disabling it was not set
|
||||||
if resolveImage == ResolveImageAlways || resolveImage == ResolveImageChanged {
|
if resolveImage == ResolveImageAlways || resolveImage == ResolveImageChanged {
|
||||||
|
@ -6,7 +6,6 @@ import (
|
|||||||
|
|
||||||
"github.com/docker/cli/cli/compose/convert"
|
"github.com/docker/cli/cli/compose/convert"
|
||||||
"github.com/docker/cli/internal/test"
|
"github.com/docker/cli/internal/test"
|
||||||
"github.com/docker/docker/api/types"
|
|
||||||
"github.com/docker/docker/api/types/swarm"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
"gotest.tools/v3/assert"
|
"gotest.tools/v3/assert"
|
||||||
is "gotest.tools/v3/assert/cmp"
|
is "gotest.tools/v3/assert/cmp"
|
||||||
@ -33,12 +32,12 @@ func TestServiceUpdateResolveImageChanged(t *testing.T) {
|
|||||||
namespace := convert.NewNamespace("mystack")
|
namespace := convert.NewNamespace("mystack")
|
||||||
|
|
||||||
var (
|
var (
|
||||||
receivedOptions types.ServiceUpdateOptions
|
receivedOptions swarm.ServiceUpdateOptions
|
||||||
receivedService swarm.ServiceSpec
|
receivedService swarm.ServiceSpec
|
||||||
)
|
)
|
||||||
|
|
||||||
client := test.NewFakeCli(&fakeClient{
|
client := test.NewFakeCli(&fakeClient{
|
||||||
serviceListFunc: func(options types.ServiceListOptions) ([]swarm.Service, error) {
|
serviceListFunc: func(options swarm.ServiceListOptions) ([]swarm.Service, error) {
|
||||||
return []swarm.Service{
|
return []swarm.Service{
|
||||||
{
|
{
|
||||||
Spec: swarm.ServiceSpec{
|
Spec: swarm.ServiceSpec{
|
||||||
@ -56,7 +55,7 @@ func TestServiceUpdateResolveImageChanged(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
serviceUpdateFunc: func(serviceID string, version swarm.Version, service swarm.ServiceSpec, options types.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error) {
|
serviceUpdateFunc: func(serviceID string, version swarm.Version, service swarm.ServiceSpec, options swarm.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error) {
|
||||||
receivedOptions = options
|
receivedOptions = options
|
||||||
receivedService = service
|
receivedService = service
|
||||||
return swarm.ServiceUpdateResponse{}, nil
|
return swarm.ServiceUpdateResponse{}, nil
|
||||||
@ -105,7 +104,7 @@ func TestServiceUpdateResolveImageChanged(t *testing.T) {
|
|||||||
assert.Check(t, is.Equal(receivedService.TaskTemplate.ForceUpdate, tc.expectedForceUpdate))
|
assert.Check(t, is.Equal(receivedService.TaskTemplate.ForceUpdate, tc.expectedForceUpdate))
|
||||||
|
|
||||||
receivedService = swarm.ServiceSpec{}
|
receivedService = swarm.ServiceSpec{}
|
||||||
receivedOptions = types.ServiceUpdateOptions{}
|
receivedOptions = swarm.ServiceUpdateOptions{}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ import (
|
|||||||
|
|
||||||
"github.com/docker/cli/cli/command/stack/formatter"
|
"github.com/docker/cli/cli/command/stack/formatter"
|
||||||
"github.com/docker/cli/cli/compose/convert"
|
"github.com/docker/cli/cli/compose/convert"
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
"github.com/docker/docker/client"
|
"github.com/docker/docker/client"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
@ -14,7 +14,7 @@ import (
|
|||||||
func GetStacks(ctx context.Context, apiClient client.ServiceAPIClient) ([]*formatter.Stack, error) {
|
func GetStacks(ctx context.Context, apiClient client.ServiceAPIClient) ([]*formatter.Stack, error) {
|
||||||
services, err := apiClient.ServiceList(
|
services, err := apiClient.ServiceList(
|
||||||
ctx,
|
ctx,
|
||||||
types.ServiceListOptions{Filters: getAllStacksFilter()})
|
swarm.ServiceListOptions{Filters: getAllStacksFilter()})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
"github.com/docker/cli/cli/command/idresolver"
|
"github.com/docker/cli/cli/command/idresolver"
|
||||||
"github.com/docker/cli/cli/command/stack/options"
|
"github.com/docker/cli/cli/command/stack/options"
|
||||||
"github.com/docker/cli/cli/command/task"
|
"github.com/docker/cli/cli/command/task"
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
)
|
)
|
||||||
|
|
||||||
// RunPS is the swarm implementation of docker stack ps
|
// 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)
|
filter := getStackFilterFromOpt(opts.Namespace, opts.Filter)
|
||||||
|
|
||||||
client := dockerCli.Client()
|
client := dockerCli.Client()
|
||||||
tasks, err := client.TaskList(ctx, types.TaskListOptions{Filters: filter})
|
tasks, err := client.TaskList(ctx, swarm.TaskListOptions{Filters: filter})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,6 @@ import (
|
|||||||
"github.com/docker/cli/cli/command"
|
"github.com/docker/cli/cli/command"
|
||||||
"github.com/docker/cli/cli/command/service"
|
"github.com/docker/cli/cli/command/service"
|
||||||
"github.com/docker/cli/cli/command/stack/options"
|
"github.com/docker/cli/cli/command/stack/options"
|
||||||
"github.com/docker/docker/api/types"
|
|
||||||
"github.com/docker/docker/api/types/swarm"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -17,7 +16,7 @@ func GetServices(ctx context.Context, dockerCli command.Cli, opts options.Servic
|
|||||||
client = dockerCli.Client()
|
client = dockerCli.Client()
|
||||||
)
|
)
|
||||||
|
|
||||||
listOpts := types.ServiceListOptions{
|
listOpts := swarm.ServiceListOptions{
|
||||||
Filters: getStackFilterFromOpt(opts.Namespace, opts.Filter),
|
Filters: getStackFilterFromOpt(opts.Namespace, opts.Filter),
|
||||||
// When not running "quiet", also get service status (number of running
|
// 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
|
// and desired tasks). Note that this is only supported on API v1.41 and
|
||||||
|
@ -3,7 +3,6 @@ package swarm
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
|
||||||
"github.com/docker/docker/api/types/swarm"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
"github.com/docker/docker/api/types/system"
|
"github.com/docker/docker/api/types/system"
|
||||||
"github.com/docker/docker/client"
|
"github.com/docker/docker/client"
|
||||||
@ -15,7 +14,7 @@ type fakeClient struct {
|
|||||||
swarmInitFunc func() (string, error)
|
swarmInitFunc func() (string, error)
|
||||||
swarmInspectFunc func() (swarm.Swarm, error)
|
swarmInspectFunc func() (swarm.Swarm, error)
|
||||||
nodeInspectFunc func() (swarm.Node, []byte, error)
|
nodeInspectFunc func() (swarm.Node, []byte, error)
|
||||||
swarmGetUnlockKeyFunc func() (types.SwarmUnlockKeyResponse, error)
|
swarmGetUnlockKeyFunc func() (swarm.UnlockKeyResponse, error)
|
||||||
swarmJoinFunc func() error
|
swarmJoinFunc func() error
|
||||||
swarmLeaveFunc func() error
|
swarmLeaveFunc func() error
|
||||||
swarmUpdateFunc func(swarm swarm.Spec, flags swarm.UpdateFlags) error
|
swarmUpdateFunc func(swarm swarm.Spec, flags swarm.UpdateFlags) error
|
||||||
@ -50,11 +49,11 @@ func (cli *fakeClient) SwarmInspect(context.Context) (swarm.Swarm, error) {
|
|||||||
return swarm.Swarm{}, nil
|
return swarm.Swarm{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cli *fakeClient) SwarmGetUnlockKey(context.Context) (types.SwarmUnlockKeyResponse, error) {
|
func (cli *fakeClient) SwarmGetUnlockKey(context.Context) (swarm.UnlockKeyResponse, error) {
|
||||||
if cli.swarmGetUnlockKeyFunc != nil {
|
if cli.swarmGetUnlockKeyFunc != nil {
|
||||||
return cli.swarmGetUnlockKeyFunc()
|
return cli.swarmGetUnlockKeyFunc()
|
||||||
}
|
}
|
||||||
return types.SwarmUnlockKeyResponse{}, nil
|
return swarm.UnlockKeyResponse{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cli *fakeClient) SwarmJoin(context.Context, swarm.JoinRequest) error {
|
func (cli *fakeClient) SwarmJoin(context.Context, swarm.JoinRequest) error {
|
||||||
|
@ -7,7 +7,6 @@ import (
|
|||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/docker/cli/internal/test"
|
"github.com/docker/cli/internal/test"
|
||||||
"github.com/docker/docker/api/types"
|
|
||||||
"github.com/docker/docker/api/types/swarm"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
"gotest.tools/v3/assert"
|
"gotest.tools/v3/assert"
|
||||||
"gotest.tools/v3/golden"
|
"gotest.tools/v3/golden"
|
||||||
@ -19,7 +18,7 @@ func TestSwarmInitErrorOnAPIFailure(t *testing.T) {
|
|||||||
flags map[string]string
|
flags map[string]string
|
||||||
swarmInitFunc func() (string, error)
|
swarmInitFunc func() (string, error)
|
||||||
swarmInspectFunc func() (swarm.Swarm, error)
|
swarmInspectFunc func() (swarm.Swarm, error)
|
||||||
swarmGetUnlockKeyFunc func() (types.SwarmUnlockKeyResponse, error)
|
swarmGetUnlockKeyFunc func() (swarm.UnlockKeyResponse, error)
|
||||||
nodeInspectFunc func() (swarm.Node, []byte, error)
|
nodeInspectFunc func() (swarm.Node, []byte, error)
|
||||||
expectedError string
|
expectedError string
|
||||||
}{
|
}{
|
||||||
@ -56,8 +55,8 @@ func TestSwarmInitErrorOnAPIFailure(t *testing.T) {
|
|||||||
flags: map[string]string{
|
flags: map[string]string{
|
||||||
flagAutolock: "true",
|
flagAutolock: "true",
|
||||||
},
|
},
|
||||||
swarmGetUnlockKeyFunc: func() (types.SwarmUnlockKeyResponse, error) {
|
swarmGetUnlockKeyFunc: func() (swarm.UnlockKeyResponse, error) {
|
||||||
return types.SwarmUnlockKeyResponse{}, errors.New("error getting swarm unlock key")
|
return swarm.UnlockKeyResponse{}, errors.New("error getting swarm unlock key")
|
||||||
},
|
},
|
||||||
expectedError: "could not fetch unlock key: error getting swarm unlock key",
|
expectedError: "could not fetch unlock key: error getting swarm unlock key",
|
||||||
},
|
},
|
||||||
@ -88,7 +87,7 @@ func TestSwarmInit(t *testing.T) {
|
|||||||
flags map[string]string
|
flags map[string]string
|
||||||
swarmInitFunc func() (string, error)
|
swarmInitFunc func() (string, error)
|
||||||
swarmInspectFunc func() (swarm.Swarm, error)
|
swarmInspectFunc func() (swarm.Swarm, error)
|
||||||
swarmGetUnlockKeyFunc func() (types.SwarmUnlockKeyResponse, error)
|
swarmGetUnlockKeyFunc func() (swarm.UnlockKeyResponse, error)
|
||||||
nodeInspectFunc func() (swarm.Node, []byte, error)
|
nodeInspectFunc func() (swarm.Node, []byte, error)
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
@ -105,8 +104,8 @@ func TestSwarmInit(t *testing.T) {
|
|||||||
swarmInitFunc: func() (string, error) {
|
swarmInitFunc: func() (string, error) {
|
||||||
return "nodeID", nil
|
return "nodeID", nil
|
||||||
},
|
},
|
||||||
swarmGetUnlockKeyFunc: func() (types.SwarmUnlockKeyResponse, error) {
|
swarmGetUnlockKeyFunc: func() (swarm.UnlockKeyResponse, error) {
|
||||||
return types.SwarmUnlockKeyResponse{
|
return swarm.UnlockKeyResponse{
|
||||||
UnlockKey: "unlock-key",
|
UnlockKey: "unlock-key",
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
|
@ -8,7 +8,6 @@ import (
|
|||||||
"os/signal"
|
"os/signal"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
|
||||||
"github.com/docker/docker/api/types/swarm"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
"github.com/docker/docker/client"
|
"github.com/docker/docker/client"
|
||||||
"github.com/docker/docker/pkg/progress"
|
"github.com/docker/docker/pkg/progress"
|
||||||
@ -52,7 +51,7 @@ func RootRotationProgress(ctx context.Context, dclient client.APIClient, progres
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
nodes, err := dclient.NodeList(ctx, types.NodeListOptions{})
|
nodes, err := dclient.NodeList(ctx, swarm.NodeListOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,6 @@ import (
|
|||||||
|
|
||||||
"github.com/docker/cli/internal/test"
|
"github.com/docker/cli/internal/test"
|
||||||
"github.com/docker/cli/internal/test/builders"
|
"github.com/docker/cli/internal/test/builders"
|
||||||
"github.com/docker/docker/api/types"
|
|
||||||
"github.com/docker/docker/api/types/swarm"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
"gotest.tools/v3/assert"
|
"gotest.tools/v3/assert"
|
||||||
"gotest.tools/v3/golden"
|
"gotest.tools/v3/golden"
|
||||||
@ -21,7 +20,7 @@ func TestSwarmUnlockKeyErrors(t *testing.T) {
|
|||||||
flags map[string]string
|
flags map[string]string
|
||||||
swarmInspectFunc func() (swarm.Swarm, error)
|
swarmInspectFunc func() (swarm.Swarm, error)
|
||||||
swarmUpdateFunc func(swarm swarm.Spec, flags swarm.UpdateFlags) error
|
swarmUpdateFunc func(swarm swarm.Spec, flags swarm.UpdateFlags) error
|
||||||
swarmGetUnlockKeyFunc func() (types.SwarmUnlockKeyResponse, error)
|
swarmGetUnlockKeyFunc func() (swarm.UnlockKeyResponse, error)
|
||||||
expectedError string
|
expectedError string
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
@ -64,17 +63,15 @@ func TestSwarmUnlockKeyErrors(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "swarm-get-unlock-key-failed",
|
name: "swarm-get-unlock-key-failed",
|
||||||
swarmGetUnlockKeyFunc: func() (types.SwarmUnlockKeyResponse, error) {
|
swarmGetUnlockKeyFunc: func() (swarm.UnlockKeyResponse, error) {
|
||||||
return types.SwarmUnlockKeyResponse{}, errors.New("error getting unlock key")
|
return swarm.UnlockKeyResponse{}, errors.New("error getting unlock key")
|
||||||
},
|
},
|
||||||
expectedError: "error getting unlock key",
|
expectedError: "error getting unlock key",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "swarm-no-unlock-key-failed",
|
name: "swarm-no-unlock-key-failed",
|
||||||
swarmGetUnlockKeyFunc: func() (types.SwarmUnlockKeyResponse, error) {
|
swarmGetUnlockKeyFunc: func() (swarm.UnlockKeyResponse, error) {
|
||||||
return types.SwarmUnlockKeyResponse{
|
return swarm.UnlockKeyResponse{}, nil
|
||||||
UnlockKey: "",
|
|
||||||
}, nil
|
|
||||||
},
|
},
|
||||||
expectedError: "no unlock key is set",
|
expectedError: "no unlock key is set",
|
||||||
},
|
},
|
||||||
@ -108,12 +105,12 @@ func TestSwarmUnlockKey(t *testing.T) {
|
|||||||
flags map[string]string
|
flags map[string]string
|
||||||
swarmInspectFunc func() (swarm.Swarm, error)
|
swarmInspectFunc func() (swarm.Swarm, error)
|
||||||
swarmUpdateFunc func(swarm swarm.Spec, flags swarm.UpdateFlags) error
|
swarmUpdateFunc func(swarm swarm.Spec, flags swarm.UpdateFlags) error
|
||||||
swarmGetUnlockKeyFunc func() (types.SwarmUnlockKeyResponse, error)
|
swarmGetUnlockKeyFunc func() (swarm.UnlockKeyResponse, error)
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "unlock-key",
|
name: "unlock-key",
|
||||||
swarmGetUnlockKeyFunc: func() (types.SwarmUnlockKeyResponse, error) {
|
swarmGetUnlockKeyFunc: func() (swarm.UnlockKeyResponse, error) {
|
||||||
return types.SwarmUnlockKeyResponse{
|
return swarm.UnlockKeyResponse{
|
||||||
UnlockKey: "unlock-key",
|
UnlockKey: "unlock-key",
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
@ -123,8 +120,8 @@ func TestSwarmUnlockKey(t *testing.T) {
|
|||||||
flags: map[string]string{
|
flags: map[string]string{
|
||||||
flagQuiet: "true",
|
flagQuiet: "true",
|
||||||
},
|
},
|
||||||
swarmGetUnlockKeyFunc: func() (types.SwarmUnlockKeyResponse, error) {
|
swarmGetUnlockKeyFunc: func() (swarm.UnlockKeyResponse, error) {
|
||||||
return types.SwarmUnlockKeyResponse{
|
return swarm.UnlockKeyResponse{
|
||||||
UnlockKey: "unlock-key",
|
UnlockKey: "unlock-key",
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
@ -137,8 +134,8 @@ func TestSwarmUnlockKey(t *testing.T) {
|
|||||||
swarmInspectFunc: func() (swarm.Swarm, error) {
|
swarmInspectFunc: func() (swarm.Swarm, error) {
|
||||||
return *builders.Swarm(builders.Autolock()), nil
|
return *builders.Swarm(builders.Autolock()), nil
|
||||||
},
|
},
|
||||||
swarmGetUnlockKeyFunc: func() (types.SwarmUnlockKeyResponse, error) {
|
swarmGetUnlockKeyFunc: func() (swarm.UnlockKeyResponse, error) {
|
||||||
return types.SwarmUnlockKeyResponse{
|
return swarm.UnlockKeyResponse{
|
||||||
UnlockKey: "unlock-key",
|
UnlockKey: "unlock-key",
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
@ -152,8 +149,8 @@ func TestSwarmUnlockKey(t *testing.T) {
|
|||||||
swarmInspectFunc: func() (swarm.Swarm, error) {
|
swarmInspectFunc: func() (swarm.Swarm, error) {
|
||||||
return *builders.Swarm(builders.Autolock()), nil
|
return *builders.Swarm(builders.Autolock()), nil
|
||||||
},
|
},
|
||||||
swarmGetUnlockKeyFunc: func() (types.SwarmUnlockKeyResponse, error) {
|
swarmGetUnlockKeyFunc: func() (swarm.UnlockKeyResponse, error) {
|
||||||
return types.SwarmUnlockKeyResponse{
|
return swarm.UnlockKeyResponse{
|
||||||
UnlockKey: "unlock-key",
|
UnlockKey: "unlock-key",
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
|
@ -9,7 +9,6 @@ import (
|
|||||||
|
|
||||||
"github.com/docker/cli/internal/test"
|
"github.com/docker/cli/internal/test"
|
||||||
"github.com/docker/cli/internal/test/builders"
|
"github.com/docker/cli/internal/test/builders"
|
||||||
"github.com/docker/docker/api/types"
|
|
||||||
"github.com/docker/docker/api/types/swarm"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
"gotest.tools/v3/assert"
|
"gotest.tools/v3/assert"
|
||||||
"gotest.tools/v3/golden"
|
"gotest.tools/v3/golden"
|
||||||
@ -22,7 +21,7 @@ func TestSwarmUpdateErrors(t *testing.T) {
|
|||||||
flags map[string]string
|
flags map[string]string
|
||||||
swarmInspectFunc func() (swarm.Swarm, error)
|
swarmInspectFunc func() (swarm.Swarm, error)
|
||||||
swarmUpdateFunc func(swarm swarm.Spec, flags swarm.UpdateFlags) error
|
swarmUpdateFunc func(swarm swarm.Spec, flags swarm.UpdateFlags) error
|
||||||
swarmGetUnlockKeyFunc func() (types.SwarmUnlockKeyResponse, error)
|
swarmGetUnlockKeyFunc func() (swarm.UnlockKeyResponse, error)
|
||||||
expectedError string
|
expectedError string
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
@ -58,8 +57,8 @@ func TestSwarmUpdateErrors(t *testing.T) {
|
|||||||
swarmInspectFunc: func() (swarm.Swarm, error) {
|
swarmInspectFunc: func() (swarm.Swarm, error) {
|
||||||
return *builders.Swarm(), nil
|
return *builders.Swarm(), nil
|
||||||
},
|
},
|
||||||
swarmGetUnlockKeyFunc: func() (types.SwarmUnlockKeyResponse, error) {
|
swarmGetUnlockKeyFunc: func() (swarm.UnlockKeyResponse, error) {
|
||||||
return types.SwarmUnlockKeyResponse{}, errors.New("error getting unlock key")
|
return swarm.UnlockKeyResponse{}, errors.New("error getting unlock key")
|
||||||
},
|
},
|
||||||
expectedError: "error getting unlock key",
|
expectedError: "error getting unlock key",
|
||||||
},
|
},
|
||||||
@ -97,7 +96,7 @@ func TestSwarmUpdate(t *testing.T) {
|
|||||||
flags map[string]string
|
flags map[string]string
|
||||||
swarmInspectFunc func() (swarm.Swarm, error)
|
swarmInspectFunc func() (swarm.Swarm, error)
|
||||||
swarmUpdateFunc func(swarm swarm.Spec, flags swarm.UpdateFlags) error
|
swarmUpdateFunc func(swarm swarm.Spec, flags swarm.UpdateFlags) error
|
||||||
swarmGetUnlockKeyFunc func() (types.SwarmUnlockKeyResponse, error)
|
swarmGetUnlockKeyFunc func() (swarm.UnlockKeyResponse, error)
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
name: "noargs",
|
name: "noargs",
|
||||||
@ -164,8 +163,8 @@ func TestSwarmUpdate(t *testing.T) {
|
|||||||
swarmInspectFunc: func() (swarm.Swarm, error) {
|
swarmInspectFunc: func() (swarm.Swarm, error) {
|
||||||
return *builders.Swarm(), nil
|
return *builders.Swarm(), nil
|
||||||
},
|
},
|
||||||
swarmGetUnlockKeyFunc: func() (types.SwarmUnlockKeyResponse, error) {
|
swarmGetUnlockKeyFunc: func() (swarm.UnlockKeyResponse, error) {
|
||||||
return types.SwarmUnlockKeyResponse{
|
return swarm.UnlockKeyResponse{
|
||||||
UnlockKey: "unlock-key",
|
UnlockKey: "unlock-key",
|
||||||
}, nil
|
}, nil
|
||||||
},
|
},
|
||||||
|
@ -26,7 +26,7 @@ type fakeClient struct {
|
|||||||
infoFunc func(ctx context.Context) (system.Info, 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 network.ListOptions) ([]network.Summary, error)
|
||||||
networkPruneFunc func(ctx context.Context, pruneFilter filters.Args) (network.PruneReport, error)
|
networkPruneFunc func(ctx context.Context, pruneFilter filters.Args) (network.PruneReport, error)
|
||||||
nodeListFunc func(ctx context.Context, options types.NodeListOptions) ([]swarm.Node, error)
|
nodeListFunc func(ctx context.Context, options swarm.NodeListOptions) ([]swarm.Node, error)
|
||||||
serverVersion func(ctx context.Context) (types.Version, 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 volume.ListOptions) (volume.ListResponse, error)
|
||||||
}
|
}
|
||||||
@ -81,7 +81,7 @@ func (cli *fakeClient) NetworksPrune(ctx context.Context, pruneFilter filters.Ar
|
|||||||
return network.PruneReport{}, nil
|
return network.PruneReport{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cli *fakeClient) NodeList(ctx context.Context, options types.NodeListOptions) ([]swarm.Node, error) {
|
func (cli *fakeClient) NodeList(ctx context.Context, options swarm.NodeListOptions) ([]swarm.Node, error) {
|
||||||
if cli.nodeListFunc != nil {
|
if cli.nodeListFunc != nil {
|
||||||
return cli.nodeListFunc(ctx, options)
|
return cli.nodeListFunc(ctx, options)
|
||||||
}
|
}
|
||||||
|
@ -4,10 +4,10 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/docker/cli/cli/command/completion"
|
"github.com/docker/cli/cli/command/completion"
|
||||||
"github.com/docker/docker/api/types"
|
|
||||||
"github.com/docker/docker/api/types/events"
|
"github.com/docker/docker/api/types/events"
|
||||||
"github.com/docker/docker/api/types/image"
|
"github.com/docker/docker/api/types/image"
|
||||||
"github.com/docker/docker/api/types/network"
|
"github.com/docker/docker/api/types/network"
|
||||||
|
"github.com/docker/docker/api/types/swarm"
|
||||||
"github.com/docker/docker/api/types/volume"
|
"github.com/docker/docker/api/types/volume"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
@ -211,7 +211,7 @@ func networkNames(dockerCLI completion.APIClientProvider, cmd *cobra.Command) []
|
|||||||
// nodeNames contacts the API to get a list of node names.
|
// nodeNames contacts the API to get a list of node names.
|
||||||
// In case of an error, an empty list is returned.
|
// In case of an error, an empty list is returned.
|
||||||
func nodeNames(dockerCLI completion.APIClientProvider, cmd *cobra.Command) []string {
|
func nodeNames(dockerCLI completion.APIClientProvider, cmd *cobra.Command) []string {
|
||||||
list, err := dockerCLI.Client().NodeList(cmd.Context(), types.NodeListOptions{})
|
list, err := dockerCLI.Client().NodeList(cmd.Context(), swarm.NodeListOptions{})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return []string{}
|
return []string{}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,6 @@ import (
|
|||||||
|
|
||||||
"github.com/docker/cli/internal/test"
|
"github.com/docker/cli/internal/test"
|
||||||
"github.com/docker/cli/internal/test/builders"
|
"github.com/docker/cli/internal/test/builders"
|
||||||
"github.com/docker/docker/api/types"
|
|
||||||
"github.com/docker/docker/api/types/container"
|
"github.com/docker/docker/api/types/container"
|
||||||
"github.com/docker/docker/api/types/image"
|
"github.com/docker/docker/api/types/image"
|
||||||
"github.com/docker/docker/api/types/network"
|
"github.com/docker/docker/api/types/network"
|
||||||
@ -111,7 +110,7 @@ func TestCompleteEventFilter(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
client: &fakeClient{
|
client: &fakeClient{
|
||||||
nodeListFunc: func(_ context.Context, _ types.NodeListOptions) ([]swarm.Node, error) {
|
nodeListFunc: func(_ context.Context, _ swarm.NodeListOptions) ([]swarm.Node, error) {
|
||||||
return []swarm.Node{
|
return []swarm.Node{
|
||||||
*builders.Node(builders.Hostname("n1")),
|
*builders.Node(builders.Hostname("n1")),
|
||||||
}, nil
|
}, nil
|
||||||
@ -122,7 +121,7 @@ func TestCompleteEventFilter(t *testing.T) {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
client: &fakeClient{
|
client: &fakeClient{
|
||||||
nodeListFunc: func(_ context.Context, _ types.NodeListOptions) ([]swarm.Node, error) {
|
nodeListFunc: func(_ context.Context, _ swarm.NodeListOptions) ([]swarm.Node, error) {
|
||||||
return []swarm.Node{}, errors.New("API error")
|
return []swarm.Node{}, errors.New("API error")
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -15,9 +15,9 @@ import (
|
|||||||
"github.com/docker/cli/cli/command/completion"
|
"github.com/docker/cli/cli/command/completion"
|
||||||
"github.com/docker/cli/cli/command/inspect"
|
"github.com/docker/cli/cli/command/inspect"
|
||||||
flagsHelper "github.com/docker/cli/cli/flags"
|
flagsHelper "github.com/docker/cli/cli/flags"
|
||||||
"github.com/docker/docker/api/types"
|
|
||||||
"github.com/docker/docker/api/types/image"
|
"github.com/docker/docker/api/types/image"
|
||||||
"github.com/docker/docker/api/types/network"
|
"github.com/docker/docker/api/types/network"
|
||||||
|
"github.com/docker/docker/api/types/swarm"
|
||||||
"github.com/docker/docker/client"
|
"github.com/docker/docker/client"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
@ -137,7 +137,7 @@ func inspectNode(ctx context.Context, dockerCli command.Cli) inspect.GetRefFunc
|
|||||||
func inspectService(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) {
|
return func(ref string) (any, []byte, error) {
|
||||||
// Service inspect shows defaults values in empty fields.
|
// Service inspect shows defaults values in empty fields.
|
||||||
return dockerCli.Client().ServiceInspectWithRaw(ctx, ref, types.ServiceInspectOptions{InsertDefaults: true})
|
return dockerCli.Client().ServiceInspectWithRaw(ctx, ref, swarm.ServiceInspectOptions{InsertDefaults: true})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@ package task
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
|
||||||
"github.com/docker/docker/api/types/swarm"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
"github.com/docker/docker/client"
|
"github.com/docker/docker/client"
|
||||||
)
|
)
|
||||||
@ -11,7 +10,7 @@ import (
|
|||||||
type fakeClient struct {
|
type fakeClient struct {
|
||||||
client.APIClient
|
client.APIClient
|
||||||
nodeInspectWithRaw func(ref string) (swarm.Node, []byte, error)
|
nodeInspectWithRaw func(ref string) (swarm.Node, []byte, error)
|
||||||
serviceInspectWithRaw func(ref string, options types.ServiceInspectOptions) (swarm.Service, []byte, error)
|
serviceInspectWithRaw func(ref string, options swarm.ServiceInspectOptions) (swarm.Service, []byte, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cli *fakeClient) NodeInspectWithRaw(_ context.Context, ref string) (swarm.Node, []byte, error) {
|
func (cli *fakeClient) NodeInspectWithRaw(_ context.Context, ref string) (swarm.Node, []byte, error) {
|
||||||
@ -21,7 +20,7 @@ func (cli *fakeClient) NodeInspectWithRaw(_ context.Context, ref string) (swarm.
|
|||||||
return swarm.Node{}, nil, nil
|
return swarm.Node{}, nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (cli *fakeClient) ServiceInspectWithRaw(_ context.Context, ref string, options types.ServiceInspectOptions) (swarm.Service, []byte, error) {
|
func (cli *fakeClient) ServiceInspectWithRaw(_ context.Context, ref string, options swarm.ServiceInspectOptions) (swarm.Service, []byte, error) {
|
||||||
if cli.serviceInspectWithRaw != nil {
|
if cli.serviceInspectWithRaw != nil {
|
||||||
return cli.serviceInspectWithRaw(ref, options)
|
return cli.serviceInspectWithRaw(ref, options)
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,6 @@ import (
|
|||||||
"github.com/docker/cli/cli/command/idresolver"
|
"github.com/docker/cli/cli/command/idresolver"
|
||||||
"github.com/docker/cli/internal/test"
|
"github.com/docker/cli/internal/test"
|
||||||
"github.com/docker/cli/internal/test/builders"
|
"github.com/docker/cli/internal/test/builders"
|
||||||
"github.com/docker/docker/api/types"
|
|
||||||
"github.com/docker/docker/api/types/swarm"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
"gotest.tools/v3/assert"
|
"gotest.tools/v3/assert"
|
||||||
"gotest.tools/v3/golden"
|
"gotest.tools/v3/golden"
|
||||||
@ -17,7 +16,7 @@ import (
|
|||||||
|
|
||||||
func TestTaskPrintSorted(t *testing.T) {
|
func TestTaskPrintSorted(t *testing.T) {
|
||||||
apiClient := &fakeClient{
|
apiClient := &fakeClient{
|
||||||
serviceInspectWithRaw: func(ref string, options types.ServiceInspectOptions) (swarm.Service, []byte, error) {
|
serviceInspectWithRaw: func(ref string, options swarm.ServiceInspectOptions) (swarm.Service, []byte, error) {
|
||||||
if ref == "service-id-one" {
|
if ref == "service-id-one" {
|
||||||
return *builders.Service(builders.ServiceName("service-name-1")), nil, nil
|
return *builders.Service(builders.ServiceName("service-name-1")), nil, nil
|
||||||
}
|
}
|
||||||
@ -109,7 +108,7 @@ func TestTaskPrintWithIndentation(t *testing.T) {
|
|||||||
const trunc = false
|
const trunc = false
|
||||||
const noResolve = false
|
const noResolve = false
|
||||||
apiClient := &fakeClient{
|
apiClient := &fakeClient{
|
||||||
serviceInspectWithRaw: func(ref string, options types.ServiceInspectOptions) (swarm.Service, []byte, error) {
|
serviceInspectWithRaw: func(ref string, options swarm.ServiceInspectOptions) (swarm.Service, []byte, error) {
|
||||||
return *builders.Service(builders.ServiceName("service-name-foo")), nil, nil
|
return *builders.Service(builders.ServiceName("service-name-foo")), nil, nil
|
||||||
},
|
},
|
||||||
nodeInspectWithRaw: func(ref string) (swarm.Node, []byte, error) {
|
nodeInspectWithRaw: func(ref string) (swarm.Node, []byte, error) {
|
||||||
@ -145,7 +144,7 @@ func TestTaskPrintWithResolution(t *testing.T) {
|
|||||||
const trunc = false
|
const trunc = false
|
||||||
const noResolve = false
|
const noResolve = false
|
||||||
apiClient := &fakeClient{
|
apiClient := &fakeClient{
|
||||||
serviceInspectWithRaw: func(ref string, options types.ServiceInspectOptions) (swarm.Service, []byte, error) {
|
serviceInspectWithRaw: func(ref string, options swarm.ServiceInspectOptions) (swarm.Service, []byte, error) {
|
||||||
return *builders.Service(builders.ServiceName("service-name-foo")), nil, nil
|
return *builders.Service(builders.ServiceName("service-name-foo")), nil, nil
|
||||||
},
|
},
|
||||||
nodeInspectWithRaw: func(ref string) (swarm.Node, []byte, error) {
|
nodeInspectWithRaw: func(ref string) (swarm.Node, []byte, error) {
|
||||||
|
@ -15,7 +15,7 @@ require (
|
|||||||
github.com/distribution/reference v0.6.0
|
github.com/distribution/reference v0.6.0
|
||||||
github.com/docker/cli-docs-tool v0.10.0
|
github.com/docker/cli-docs-tool v0.10.0
|
||||||
github.com/docker/distribution v2.8.3+incompatible
|
github.com/docker/distribution v2.8.3+incompatible
|
||||||
github.com/docker/docker v28.1.2-0.20250519114040-7937f0846c13+incompatible // master, v28.x dev
|
github.com/docker/docker v28.2.0-rc.1.0.20250519201520-8601b22f5db5+incompatible // master, v28.2-dev
|
||||||
github.com/docker/docker-credential-helpers v0.9.3
|
github.com/docker/docker-credential-helpers v0.9.3
|
||||||
github.com/docker/go-connections v0.5.0
|
github.com/docker/go-connections v0.5.0
|
||||||
github.com/docker/go-units v0.5.0
|
github.com/docker/go-units v0.5.0
|
||||||
|
@ -55,8 +55,8 @@ github.com/docker/cli-docs-tool v0.10.0/go.mod h1:5EM5zPnT2E7yCLERZmrDA234Vwn09f
|
|||||||
github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
|
github.com/docker/distribution v2.7.1+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
|
||||||
github.com/docker/distribution v2.8.3+incompatible h1:AtKxIZ36LoNK51+Z6RpzLpddBirtxJnzDrHLEKxTAYk=
|
github.com/docker/distribution v2.8.3+incompatible h1:AtKxIZ36LoNK51+Z6RpzLpddBirtxJnzDrHLEKxTAYk=
|
||||||
github.com/docker/distribution v2.8.3+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
|
github.com/docker/distribution v2.8.3+incompatible/go.mod h1:J2gT2udsDAN96Uj4KfcMRqY0/ypR+oyYUYmja8H+y+w=
|
||||||
github.com/docker/docker v28.1.2-0.20250519114040-7937f0846c13+incompatible h1:hQ0dI0strJB2gjh/Sx+WthVEhOe89DPjAwiZVwjbpIg=
|
github.com/docker/docker v28.2.0-rc.1.0.20250519201520-8601b22f5db5+incompatible h1:lRjUQk5O0hf8SBkjc9KNTePPhldGmNmVA+ykOS6Pg4A=
|
||||||
github.com/docker/docker v28.1.2-0.20250519114040-7937f0846c13+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
|
github.com/docker/docker v28.2.0-rc.1.0.20250519201520-8601b22f5db5+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk=
|
||||||
github.com/docker/docker-credential-helpers v0.9.3 h1:gAm/VtF9wgqJMoxzT3Gj5p4AqIjCBS4wrsOh9yRqcz8=
|
github.com/docker/docker-credential-helpers v0.9.3 h1:gAm/VtF9wgqJMoxzT3Gj5p4AqIjCBS4wrsOh9yRqcz8=
|
||||||
github.com/docker/docker-credential-helpers v0.9.3/go.mod h1:x+4Gbw9aGmChi3qTLZj8Dfn0TD20M/fuWy0E5+WDeCo=
|
github.com/docker/docker-credential-helpers v0.9.3/go.mod h1:x+4Gbw9aGmChi3qTLZj8Dfn0TD20M/fuWy0E5+WDeCo=
|
||||||
github.com/docker/go v1.5.1-1.0.20160303222718-d30aec9fd63c h1:lzqkGL9b3znc+ZUgi7FlLnqjQhcXxkNM/quxIjBVMD0=
|
github.com/docker/go v1.5.1-1.0.20160303222718-d30aec9fd63c h1:lzqkGL9b3znc+ZUgi7FlLnqjQhcXxkNM/quxIjBVMD0=
|
||||||
|
90
vendor/github.com/docker/docker/api/types/client.go
generated
vendored
90
vendor/github.com/docker/docker/api/types/client.go
generated
vendored
@ -4,8 +4,6 @@ import (
|
|||||||
"bufio"
|
"bufio"
|
||||||
"context"
|
"context"
|
||||||
"net"
|
"net"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types/filters"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// NewHijackedResponse initializes a [HijackedResponse] type.
|
// NewHijackedResponse initializes a [HijackedResponse] type.
|
||||||
@ -48,87 +46,6 @@ func (h *HijackedResponse) CloseWrite() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// NodeListOptions holds parameters to list nodes with.
|
|
||||||
type NodeListOptions struct {
|
|
||||||
Filters filters.Args
|
|
||||||
}
|
|
||||||
|
|
||||||
// NodeRemoveOptions holds parameters to remove nodes with.
|
|
||||||
type NodeRemoveOptions struct {
|
|
||||||
Force bool
|
|
||||||
}
|
|
||||||
|
|
||||||
// ServiceCreateOptions contains the options to use when creating a service.
|
|
||||||
type ServiceCreateOptions struct {
|
|
||||||
// EncodedRegistryAuth is the encoded registry authorization credentials to
|
|
||||||
// use when updating the service.
|
|
||||||
//
|
|
||||||
// This field follows the format of the X-Registry-Auth header.
|
|
||||||
EncodedRegistryAuth string
|
|
||||||
|
|
||||||
// QueryRegistry indicates whether the service update requires
|
|
||||||
// contacting a registry. A registry may be contacted to retrieve
|
|
||||||
// the image digest and manifest, which in turn can be used to update
|
|
||||||
// platform or other information about the service.
|
|
||||||
QueryRegistry bool
|
|
||||||
}
|
|
||||||
|
|
||||||
// Values for RegistryAuthFrom in ServiceUpdateOptions
|
|
||||||
const (
|
|
||||||
RegistryAuthFromSpec = "spec"
|
|
||||||
RegistryAuthFromPreviousSpec = "previous-spec"
|
|
||||||
)
|
|
||||||
|
|
||||||
// ServiceUpdateOptions contains the options to be used for updating services.
|
|
||||||
type ServiceUpdateOptions struct {
|
|
||||||
// EncodedRegistryAuth is the encoded registry authorization credentials to
|
|
||||||
// use when updating the service.
|
|
||||||
//
|
|
||||||
// This field follows the format of the X-Registry-Auth header.
|
|
||||||
EncodedRegistryAuth string
|
|
||||||
|
|
||||||
// TODO(stevvooe): Consider moving the version parameter of ServiceUpdate
|
|
||||||
// into this field. While it does open API users up to racy writes, most
|
|
||||||
// users may not need that level of consistency in practice.
|
|
||||||
|
|
||||||
// RegistryAuthFrom specifies where to find the registry authorization
|
|
||||||
// credentials if they are not given in EncodedRegistryAuth. Valid
|
|
||||||
// values are "spec" and "previous-spec".
|
|
||||||
RegistryAuthFrom string
|
|
||||||
|
|
||||||
// Rollback indicates whether a server-side rollback should be
|
|
||||||
// performed. When this is set, the provided spec will be ignored.
|
|
||||||
// The valid values are "previous" and "none". An empty value is the
|
|
||||||
// same as "none".
|
|
||||||
Rollback string
|
|
||||||
|
|
||||||
// QueryRegistry indicates whether the service update requires
|
|
||||||
// contacting a registry. A registry may be contacted to retrieve
|
|
||||||
// the image digest and manifest, which in turn can be used to update
|
|
||||||
// platform or other information about the service.
|
|
||||||
QueryRegistry bool
|
|
||||||
}
|
|
||||||
|
|
||||||
// ServiceListOptions holds parameters to list services with.
|
|
||||||
type ServiceListOptions struct {
|
|
||||||
Filters filters.Args
|
|
||||||
|
|
||||||
// Status indicates whether the server should include the service task
|
|
||||||
// count of running and desired tasks.
|
|
||||||
Status bool
|
|
||||||
}
|
|
||||||
|
|
||||||
// ServiceInspectOptions holds parameters related to the "service inspect"
|
|
||||||
// operation.
|
|
||||||
type ServiceInspectOptions struct {
|
|
||||||
InsertDefaults bool
|
|
||||||
}
|
|
||||||
|
|
||||||
// TaskListOptions holds parameters to list tasks with.
|
|
||||||
type TaskListOptions struct {
|
|
||||||
Filters filters.Args
|
|
||||||
}
|
|
||||||
|
|
||||||
// PluginRemoveOptions holds parameters to remove plugins.
|
// PluginRemoveOptions holds parameters to remove plugins.
|
||||||
type PluginRemoveOptions struct {
|
type PluginRemoveOptions struct {
|
||||||
Force bool
|
Force bool
|
||||||
@ -162,13 +79,6 @@ type PluginInstallOptions struct {
|
|||||||
Args []string
|
Args []string
|
||||||
}
|
}
|
||||||
|
|
||||||
// SwarmUnlockKeyResponse contains the response for Engine API:
|
|
||||||
// GET /swarm/unlockkey
|
|
||||||
type SwarmUnlockKeyResponse struct {
|
|
||||||
// UnlockKey is the unlock key in ASCII-armored format.
|
|
||||||
UnlockKey string
|
|
||||||
}
|
|
||||||
|
|
||||||
// PluginCreateOptions hold all options to plugin create.
|
// PluginCreateOptions hold all options to plugin create.
|
||||||
type PluginCreateOptions struct {
|
type PluginCreateOptions struct {
|
||||||
RepoName string
|
RepoName string
|
||||||
|
11
vendor/github.com/docker/docker/api/types/swarm/node.go
generated
vendored
11
vendor/github.com/docker/docker/api/types/swarm/node.go
generated
vendored
@ -1,4 +1,5 @@
|
|||||||
package swarm // import "github.com/docker/docker/api/types/swarm"
|
package swarm // import "github.com/docker/docker/api/types/swarm"
|
||||||
|
import "github.com/docker/docker/api/types/filters"
|
||||||
|
|
||||||
// Node represents a node.
|
// Node represents a node.
|
||||||
type Node struct {
|
type Node struct {
|
||||||
@ -137,3 +138,13 @@ const (
|
|||||||
type Topology struct {
|
type Topology struct {
|
||||||
Segments map[string]string `json:",omitempty"`
|
Segments map[string]string `json:",omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NodeListOptions holds parameters to list nodes with.
|
||||||
|
type NodeListOptions struct {
|
||||||
|
Filters filters.Args
|
||||||
|
}
|
||||||
|
|
||||||
|
// NodeRemoveOptions holds parameters to remove nodes with.
|
||||||
|
type NodeRemoveOptions struct {
|
||||||
|
Force bool
|
||||||
|
}
|
||||||
|
72
vendor/github.com/docker/docker/api/types/swarm/service.go
generated
vendored
72
vendor/github.com/docker/docker/api/types/swarm/service.go
generated
vendored
@ -1,6 +1,10 @@
|
|||||||
package swarm // import "github.com/docker/docker/api/types/swarm"
|
package swarm // import "github.com/docker/docker/api/types/swarm"
|
||||||
|
|
||||||
import "time"
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/docker/docker/api/types/filters"
|
||||||
|
)
|
||||||
|
|
||||||
// Service represents a service.
|
// Service represents a service.
|
||||||
type Service struct {
|
type Service struct {
|
||||||
@ -200,3 +204,69 @@ type JobStatus struct {
|
|||||||
// Swarm manager.
|
// Swarm manager.
|
||||||
LastExecution time.Time `json:",omitempty"`
|
LastExecution time.Time `json:",omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ServiceCreateOptions contains the options to use when creating a service.
|
||||||
|
type ServiceCreateOptions struct {
|
||||||
|
// EncodedRegistryAuth is the encoded registry authorization credentials to
|
||||||
|
// use when updating the service.
|
||||||
|
//
|
||||||
|
// This field follows the format of the X-Registry-Auth header.
|
||||||
|
EncodedRegistryAuth string
|
||||||
|
|
||||||
|
// QueryRegistry indicates whether the service update requires
|
||||||
|
// contacting a registry. A registry may be contacted to retrieve
|
||||||
|
// the image digest and manifest, which in turn can be used to update
|
||||||
|
// platform or other information about the service.
|
||||||
|
QueryRegistry bool
|
||||||
|
}
|
||||||
|
|
||||||
|
// Values for RegistryAuthFrom in ServiceUpdateOptions
|
||||||
|
const (
|
||||||
|
RegistryAuthFromSpec = "spec"
|
||||||
|
RegistryAuthFromPreviousSpec = "previous-spec"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ServiceUpdateOptions contains the options to be used for updating services.
|
||||||
|
type ServiceUpdateOptions struct {
|
||||||
|
// EncodedRegistryAuth is the encoded registry authorization credentials to
|
||||||
|
// use when updating the service.
|
||||||
|
//
|
||||||
|
// This field follows the format of the X-Registry-Auth header.
|
||||||
|
EncodedRegistryAuth string
|
||||||
|
|
||||||
|
// TODO(stevvooe): Consider moving the version parameter of ServiceUpdate
|
||||||
|
// into this field. While it does open API users up to racy writes, most
|
||||||
|
// users may not need that level of consistency in practice.
|
||||||
|
|
||||||
|
// RegistryAuthFrom specifies where to find the registry authorization
|
||||||
|
// credentials if they are not given in EncodedRegistryAuth. Valid
|
||||||
|
// values are "spec" and "previous-spec".
|
||||||
|
RegistryAuthFrom string
|
||||||
|
|
||||||
|
// Rollback indicates whether a server-side rollback should be
|
||||||
|
// performed. When this is set, the provided spec will be ignored.
|
||||||
|
// The valid values are "previous" and "none". An empty value is the
|
||||||
|
// same as "none".
|
||||||
|
Rollback string
|
||||||
|
|
||||||
|
// QueryRegistry indicates whether the service update requires
|
||||||
|
// contacting a registry. A registry may be contacted to retrieve
|
||||||
|
// the image digest and manifest, which in turn can be used to update
|
||||||
|
// platform or other information about the service.
|
||||||
|
QueryRegistry bool
|
||||||
|
}
|
||||||
|
|
||||||
|
// ServiceListOptions holds parameters to list services with.
|
||||||
|
type ServiceListOptions struct {
|
||||||
|
Filters filters.Args
|
||||||
|
|
||||||
|
// Status indicates whether the server should include the service task
|
||||||
|
// count of running and desired tasks.
|
||||||
|
Status bool
|
||||||
|
}
|
||||||
|
|
||||||
|
// ServiceInspectOptions holds parameters related to the "service inspect"
|
||||||
|
// operation.
|
||||||
|
type ServiceInspectOptions struct {
|
||||||
|
InsertDefaults bool
|
||||||
|
}
|
||||||
|
7
vendor/github.com/docker/docker/api/types/swarm/swarm.go
generated
vendored
7
vendor/github.com/docker/docker/api/types/swarm/swarm.go
generated
vendored
@ -235,3 +235,10 @@ type UpdateFlags struct {
|
|||||||
RotateManagerToken bool
|
RotateManagerToken bool
|
||||||
RotateManagerUnlockKey bool
|
RotateManagerUnlockKey bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// UnlockKeyResponse contains the response for Engine API:
|
||||||
|
// GET /swarm/unlockkey
|
||||||
|
type UnlockKeyResponse struct {
|
||||||
|
// UnlockKey is the unlock key in ASCII-armored format.
|
||||||
|
UnlockKey string
|
||||||
|
}
|
||||||
|
6
vendor/github.com/docker/docker/api/types/swarm/task.go
generated
vendored
6
vendor/github.com/docker/docker/api/types/swarm/task.go
generated
vendored
@ -3,6 +3,7 @@ package swarm // import "github.com/docker/docker/api/types/swarm"
|
|||||||
import (
|
import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/docker/docker/api/types/filters"
|
||||||
"github.com/docker/docker/api/types/swarm/runtime"
|
"github.com/docker/docker/api/types/swarm/runtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -223,3 +224,8 @@ type VolumeAttachment struct {
|
|||||||
// in the ContainerSpec, that this volume fulfills.
|
// in the ContainerSpec, that this volume fulfills.
|
||||||
Target string `json:",omitempty"`
|
Target string `json:",omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TaskListOptions holds parameters to list tasks with.
|
||||||
|
type TaskListOptions struct {
|
||||||
|
Filters filters.Args
|
||||||
|
}
|
||||||
|
47
vendor/github.com/docker/docker/api/types/types_deprecated.go
generated
vendored
47
vendor/github.com/docker/docker/api/types/types_deprecated.go
generated
vendored
@ -138,6 +138,53 @@ type ConfigCreateResponse = swarm.ConfigCreateResponse
|
|||||||
// Deprecated: use [swarm.ConfigListOptions].
|
// Deprecated: use [swarm.ConfigListOptions].
|
||||||
type ConfigListOptions = swarm.ConfigListOptions
|
type ConfigListOptions = swarm.ConfigListOptions
|
||||||
|
|
||||||
|
// NodeListOptions holds parameters to list nodes with.
|
||||||
|
//
|
||||||
|
// Deprecated: use [swarm.NodeListOptions].
|
||||||
|
type NodeListOptions = swarm.NodeListOptions
|
||||||
|
|
||||||
|
// NodeRemoveOptions holds parameters to remove nodes with.
|
||||||
|
//
|
||||||
|
// Deprecated: use [swarm.NodeRemoveOptions].
|
||||||
|
type NodeRemoveOptions = swarm.NodeRemoveOptions
|
||||||
|
|
||||||
|
// TaskListOptions holds parameters to list tasks with.
|
||||||
|
//
|
||||||
|
// Deprecated: use [swarm.TaskListOptions].
|
||||||
|
type TaskListOptions = swarm.TaskListOptions
|
||||||
|
|
||||||
|
// ServiceCreateOptions contains the options to use when creating a service.
|
||||||
|
//
|
||||||
|
// Deprecated: use [swarm.ServiceCreateOptions].
|
||||||
|
type ServiceCreateOptions = swarm.ServiceCreateOptions
|
||||||
|
|
||||||
|
// ServiceUpdateOptions contains the options to be used for updating services.
|
||||||
|
//
|
||||||
|
// Deprecated: use [swarm.ServiceCreateOptions].
|
||||||
|
type ServiceUpdateOptions = swarm.ServiceUpdateOptions
|
||||||
|
|
||||||
|
const (
|
||||||
|
RegistryAuthFromSpec = swarm.RegistryAuthFromSpec // Deprecated: use [swarm.RegistryAuthFromSpec].
|
||||||
|
RegistryAuthFromPreviousSpec = swarm.RegistryAuthFromPreviousSpec // Deprecated: use [swarm.RegistryAuthFromPreviousSpec].
|
||||||
|
)
|
||||||
|
|
||||||
|
// ServiceListOptions holds parameters to list services with.
|
||||||
|
//
|
||||||
|
// Deprecated: use [swarm.ServiceListOptions].
|
||||||
|
type ServiceListOptions = swarm.ServiceListOptions
|
||||||
|
|
||||||
|
// ServiceInspectOptions holds parameters related to the "service inspect"
|
||||||
|
// operation.
|
||||||
|
//
|
||||||
|
// Deprecated: use [swarm.ServiceInspectOptions].
|
||||||
|
type ServiceInspectOptions = swarm.ServiceInspectOptions
|
||||||
|
|
||||||
|
// SwarmUnlockKeyResponse contains the response for Engine API:
|
||||||
|
// GET /swarm/unlockkey
|
||||||
|
//
|
||||||
|
// Deprecated: use [swarm.UnlockKeyResponse].
|
||||||
|
type SwarmUnlockKeyResponse = swarm.UnlockKeyResponse
|
||||||
|
|
||||||
// BuildCache contains information about a build cache record.
|
// BuildCache contains information about a build cache record.
|
||||||
//
|
//
|
||||||
// Deprecated: deprecated in API 1.49. Use [build.CacheRecord] instead.
|
// Deprecated: deprecated in API 1.49. Use [build.CacheRecord] instead.
|
||||||
|
16
vendor/github.com/docker/docker/client/client_interfaces.go
generated
vendored
16
vendor/github.com/docker/docker/client/client_interfaces.go
generated
vendored
@ -155,8 +155,8 @@ type NetworkAPIClient interface {
|
|||||||
// NodeAPIClient defines API client methods for the nodes
|
// NodeAPIClient defines API client methods for the nodes
|
||||||
type NodeAPIClient interface {
|
type NodeAPIClient interface {
|
||||||
NodeInspectWithRaw(ctx context.Context, nodeID string) (swarm.Node, []byte, error)
|
NodeInspectWithRaw(ctx context.Context, nodeID string) (swarm.Node, []byte, error)
|
||||||
NodeList(ctx context.Context, options types.NodeListOptions) ([]swarm.Node, error)
|
NodeList(ctx context.Context, options swarm.NodeListOptions) ([]swarm.Node, error)
|
||||||
NodeRemove(ctx context.Context, nodeID string, options types.NodeRemoveOptions) error
|
NodeRemove(ctx context.Context, nodeID string, options swarm.NodeRemoveOptions) error
|
||||||
NodeUpdate(ctx context.Context, nodeID string, version swarm.Version, node swarm.NodeSpec) error
|
NodeUpdate(ctx context.Context, nodeID string, version swarm.Version, node swarm.NodeSpec) error
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,22 +176,22 @@ type PluginAPIClient interface {
|
|||||||
|
|
||||||
// ServiceAPIClient defines API client methods for the services
|
// ServiceAPIClient defines API client methods for the services
|
||||||
type ServiceAPIClient interface {
|
type ServiceAPIClient interface {
|
||||||
ServiceCreate(ctx context.Context, service swarm.ServiceSpec, options types.ServiceCreateOptions) (swarm.ServiceCreateResponse, error)
|
ServiceCreate(ctx context.Context, service swarm.ServiceSpec, options swarm.ServiceCreateOptions) (swarm.ServiceCreateResponse, error)
|
||||||
ServiceInspectWithRaw(ctx context.Context, serviceID string, options types.ServiceInspectOptions) (swarm.Service, []byte, error)
|
ServiceInspectWithRaw(ctx context.Context, serviceID string, options swarm.ServiceInspectOptions) (swarm.Service, []byte, error)
|
||||||
ServiceList(ctx context.Context, options types.ServiceListOptions) ([]swarm.Service, error)
|
ServiceList(ctx context.Context, options swarm.ServiceListOptions) ([]swarm.Service, error)
|
||||||
ServiceRemove(ctx context.Context, serviceID string) error
|
ServiceRemove(ctx context.Context, serviceID string) error
|
||||||
ServiceUpdate(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options types.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error)
|
ServiceUpdate(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options swarm.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error)
|
||||||
ServiceLogs(ctx context.Context, serviceID string, options container.LogsOptions) (io.ReadCloser, error)
|
ServiceLogs(ctx context.Context, serviceID string, options container.LogsOptions) (io.ReadCloser, error)
|
||||||
TaskLogs(ctx context.Context, taskID string, options container.LogsOptions) (io.ReadCloser, error)
|
TaskLogs(ctx context.Context, taskID string, options container.LogsOptions) (io.ReadCloser, error)
|
||||||
TaskInspectWithRaw(ctx context.Context, taskID string) (swarm.Task, []byte, error)
|
TaskInspectWithRaw(ctx context.Context, taskID string) (swarm.Task, []byte, error)
|
||||||
TaskList(ctx context.Context, options types.TaskListOptions) ([]swarm.Task, error)
|
TaskList(ctx context.Context, options swarm.TaskListOptions) ([]swarm.Task, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// SwarmAPIClient defines API client methods for the swarm
|
// SwarmAPIClient defines API client methods for the swarm
|
||||||
type SwarmAPIClient interface {
|
type SwarmAPIClient interface {
|
||||||
SwarmInit(ctx context.Context, req swarm.InitRequest) (string, error)
|
SwarmInit(ctx context.Context, req swarm.InitRequest) (string, error)
|
||||||
SwarmJoin(ctx context.Context, req swarm.JoinRequest) error
|
SwarmJoin(ctx context.Context, req swarm.JoinRequest) error
|
||||||
SwarmGetUnlockKey(ctx context.Context) (types.SwarmUnlockKeyResponse, error)
|
SwarmGetUnlockKey(ctx context.Context) (swarm.UnlockKeyResponse, error)
|
||||||
SwarmUnlock(ctx context.Context, req swarm.UnlockRequest) error
|
SwarmUnlock(ctx context.Context, req swarm.UnlockRequest) error
|
||||||
SwarmLeave(ctx context.Context, force bool) error
|
SwarmLeave(ctx context.Context, force bool) error
|
||||||
SwarmInspect(ctx context.Context) (swarm.Swarm, error)
|
SwarmInspect(ctx context.Context) (swarm.Swarm, error)
|
||||||
|
4
vendor/github.com/docker/docker/client/image_pull.go
generated
vendored
4
vendor/github.com/docker/docker/client/image_pull.go
generated
vendored
@ -6,9 +6,9 @@ import (
|
|||||||
"net/url"
|
"net/url"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
cerrdefs "github.com/containerd/errdefs"
|
||||||
"github.com/distribution/reference"
|
"github.com/distribution/reference"
|
||||||
"github.com/docker/docker/api/types/image"
|
"github.com/docker/docker/api/types/image"
|
||||||
"github.com/docker/docker/errdefs"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// ImagePull requests the docker host to pull an image from a remote registry.
|
// ImagePull requests the docker host to pull an image from a remote registry.
|
||||||
@ -35,7 +35,7 @@ func (cli *Client) ImagePull(ctx context.Context, refStr string, options image.P
|
|||||||
}
|
}
|
||||||
|
|
||||||
resp, err := cli.tryImageCreate(ctx, query, options.RegistryAuth)
|
resp, err := cli.tryImageCreate(ctx, query, options.RegistryAuth)
|
||||||
if errdefs.IsUnauthorized(err) && options.PrivilegeFunc != nil {
|
if cerrdefs.IsUnauthorized(err) && options.PrivilegeFunc != nil {
|
||||||
newAuthHeader, privilegeErr := options.PrivilegeFunc(ctx)
|
newAuthHeader, privilegeErr := options.PrivilegeFunc(ctx)
|
||||||
if privilegeErr != nil {
|
if privilegeErr != nil {
|
||||||
return nil, privilegeErr
|
return nil, privilegeErr
|
||||||
|
4
vendor/github.com/docker/docker/client/image_push.go
generated
vendored
4
vendor/github.com/docker/docker/client/image_push.go
generated
vendored
@ -9,10 +9,10 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
|
cerrdefs "github.com/containerd/errdefs"
|
||||||
"github.com/distribution/reference"
|
"github.com/distribution/reference"
|
||||||
"github.com/docker/docker/api/types/image"
|
"github.com/docker/docker/api/types/image"
|
||||||
"github.com/docker/docker/api/types/registry"
|
"github.com/docker/docker/api/types/registry"
|
||||||
"github.com/docker/docker/errdefs"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// ImagePush requests the docker host to push an image to a remote registry.
|
// ImagePush requests the docker host to push an image to a remote registry.
|
||||||
@ -52,7 +52,7 @@ func (cli *Client) ImagePush(ctx context.Context, image string, options image.Pu
|
|||||||
}
|
}
|
||||||
|
|
||||||
resp, err := cli.tryImagePush(ctx, ref.Name(), query, options.RegistryAuth)
|
resp, err := cli.tryImagePush(ctx, ref.Name(), query, options.RegistryAuth)
|
||||||
if errdefs.IsUnauthorized(err) && options.PrivilegeFunc != nil {
|
if cerrdefs.IsUnauthorized(err) && options.PrivilegeFunc != nil {
|
||||||
newAuthHeader, privilegeErr := options.PrivilegeFunc(ctx)
|
newAuthHeader, privilegeErr := options.PrivilegeFunc(ctx)
|
||||||
if privilegeErr != nil {
|
if privilegeErr != nil {
|
||||||
return nil, privilegeErr
|
return nil, privilegeErr
|
||||||
|
4
vendor/github.com/docker/docker/client/image_search.go
generated
vendored
4
vendor/github.com/docker/docker/client/image_search.go
generated
vendored
@ -7,9 +7,9 @@ import (
|
|||||||
"net/url"
|
"net/url"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
cerrdefs "github.com/containerd/errdefs"
|
||||||
"github.com/docker/docker/api/types/filters"
|
"github.com/docker/docker/api/types/filters"
|
||||||
"github.com/docker/docker/api/types/registry"
|
"github.com/docker/docker/api/types/registry"
|
||||||
"github.com/docker/docker/errdefs"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// ImageSearch makes the docker host search by a term in a remote registry.
|
// ImageSearch makes the docker host search by a term in a remote registry.
|
||||||
@ -32,7 +32,7 @@ func (cli *Client) ImageSearch(ctx context.Context, term string, options registr
|
|||||||
|
|
||||||
resp, err := cli.tryImageSearch(ctx, query, options.RegistryAuth)
|
resp, err := cli.tryImageSearch(ctx, query, options.RegistryAuth)
|
||||||
defer ensureReaderClosed(resp)
|
defer ensureReaderClosed(resp)
|
||||||
if errdefs.IsUnauthorized(err) && options.PrivilegeFunc != nil {
|
if cerrdefs.IsUnauthorized(err) && options.PrivilegeFunc != nil {
|
||||||
newAuthHeader, privilegeErr := options.PrivilegeFunc(ctx)
|
newAuthHeader, privilegeErr := options.PrivilegeFunc(ctx)
|
||||||
if privilegeErr != nil {
|
if privilegeErr != nil {
|
||||||
return results, privilegeErr
|
return results, privilegeErr
|
||||||
|
3
vendor/github.com/docker/docker/client/node_list.go
generated
vendored
3
vendor/github.com/docker/docker/client/node_list.go
generated
vendored
@ -5,13 +5,12 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
|
||||||
"github.com/docker/docker/api/types/filters"
|
"github.com/docker/docker/api/types/filters"
|
||||||
"github.com/docker/docker/api/types/swarm"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
)
|
)
|
||||||
|
|
||||||
// NodeList returns the list of nodes.
|
// NodeList returns the list of nodes.
|
||||||
func (cli *Client) NodeList(ctx context.Context, options types.NodeListOptions) ([]swarm.Node, error) {
|
func (cli *Client) NodeList(ctx context.Context, options swarm.NodeListOptions) ([]swarm.Node, error) {
|
||||||
query := url.Values{}
|
query := url.Values{}
|
||||||
|
|
||||||
if options.Filters.Len() > 0 {
|
if options.Filters.Len() > 0 {
|
||||||
|
4
vendor/github.com/docker/docker/client/node_remove.go
generated
vendored
4
vendor/github.com/docker/docker/client/node_remove.go
generated
vendored
@ -4,11 +4,11 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
)
|
)
|
||||||
|
|
||||||
// NodeRemove removes a Node.
|
// NodeRemove removes a Node.
|
||||||
func (cli *Client) NodeRemove(ctx context.Context, nodeID string, options types.NodeRemoveOptions) error {
|
func (cli *Client) NodeRemove(ctx context.Context, nodeID string, options swarm.NodeRemoveOptions) error {
|
||||||
nodeID, err := trimID("node", nodeID)
|
nodeID, err := trimID("node", nodeID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
4
vendor/github.com/docker/docker/client/plugin_install.go
generated
vendored
4
vendor/github.com/docker/docker/client/plugin_install.go
generated
vendored
@ -7,10 +7,10 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
|
cerrdefs "github.com/containerd/errdefs"
|
||||||
"github.com/distribution/reference"
|
"github.com/distribution/reference"
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
"github.com/docker/docker/api/types/registry"
|
"github.com/docker/docker/api/types/registry"
|
||||||
"github.com/docker/docker/errdefs"
|
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -82,7 +82,7 @@ func (cli *Client) tryPluginPull(ctx context.Context, query url.Values, privileg
|
|||||||
|
|
||||||
func (cli *Client) checkPluginPermissions(ctx context.Context, query url.Values, options types.PluginInstallOptions) (types.PluginPrivileges, error) {
|
func (cli *Client) checkPluginPermissions(ctx context.Context, query url.Values, options types.PluginInstallOptions) (types.PluginPrivileges, error) {
|
||||||
resp, err := cli.tryPluginPrivileges(ctx, query, options.RegistryAuth)
|
resp, err := cli.tryPluginPrivileges(ctx, query, options.RegistryAuth)
|
||||||
if errdefs.IsUnauthorized(err) && options.PrivilegeFunc != nil {
|
if cerrdefs.IsUnauthorized(err) && options.PrivilegeFunc != nil {
|
||||||
// todo: do inspect before to check existing name before checking privileges
|
// todo: do inspect before to check existing name before checking privileges
|
||||||
newAuthHeader, privilegeErr := options.PrivilegeFunc(ctx)
|
newAuthHeader, privilegeErr := options.PrivilegeFunc(ctx)
|
||||||
if privilegeErr != nil {
|
if privilegeErr != nil {
|
||||||
|
6
vendor/github.com/docker/docker/client/request.go
generated
vendored
6
vendor/github.com/docker/docker/client/request.go
generated
vendored
@ -116,10 +116,8 @@ func (cli *Client) sendRequest(ctx context.Context, method, path string, query u
|
|||||||
|
|
||||||
resp, err := cli.doRequest(req)
|
resp, err := cli.doRequest(req)
|
||||||
switch {
|
switch {
|
||||||
case errors.Is(err, context.Canceled):
|
case errors.Is(err, context.Canceled), errors.Is(err, context.DeadlineExceeded):
|
||||||
return nil, errdefs.Cancelled(err)
|
return nil, err
|
||||||
case errors.Is(err, context.DeadlineExceeded):
|
|
||||||
return nil, errdefs.Deadline(err)
|
|
||||||
case err == nil:
|
case err == nil:
|
||||||
return resp, cli.checkResponseErr(resp)
|
return resp, cli.checkResponseErr(resp)
|
||||||
default:
|
default:
|
||||||
|
3
vendor/github.com/docker/docker/client/service_create.go
generated
vendored
3
vendor/github.com/docker/docker/client/service_create.go
generated
vendored
@ -8,7 +8,6 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/distribution/reference"
|
"github.com/distribution/reference"
|
||||||
"github.com/docker/docker/api/types"
|
|
||||||
"github.com/docker/docker/api/types/registry"
|
"github.com/docker/docker/api/types/registry"
|
||||||
"github.com/docker/docker/api/types/swarm"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
"github.com/docker/docker/api/types/versions"
|
"github.com/docker/docker/api/types/versions"
|
||||||
@ -17,7 +16,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
// ServiceCreate creates a new service.
|
// ServiceCreate creates a new service.
|
||||||
func (cli *Client) ServiceCreate(ctx context.Context, service swarm.ServiceSpec, options types.ServiceCreateOptions) (swarm.ServiceCreateResponse, error) {
|
func (cli *Client) ServiceCreate(ctx context.Context, service swarm.ServiceSpec, options swarm.ServiceCreateOptions) (swarm.ServiceCreateResponse, error) {
|
||||||
var response swarm.ServiceCreateResponse
|
var response swarm.ServiceCreateResponse
|
||||||
|
|
||||||
// Make sure we negotiated (if the client is configured to do so),
|
// Make sure we negotiated (if the client is configured to do so),
|
||||||
|
3
vendor/github.com/docker/docker/client/service_inspect.go
generated
vendored
3
vendor/github.com/docker/docker/client/service_inspect.go
generated
vendored
@ -8,12 +8,11 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
|
||||||
"github.com/docker/docker/api/types/swarm"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ServiceInspectWithRaw returns the service information and the raw data.
|
// ServiceInspectWithRaw returns the service information and the raw data.
|
||||||
func (cli *Client) ServiceInspectWithRaw(ctx context.Context, serviceID string, opts types.ServiceInspectOptions) (swarm.Service, []byte, error) {
|
func (cli *Client) ServiceInspectWithRaw(ctx context.Context, serviceID string, opts swarm.ServiceInspectOptions) (swarm.Service, []byte, error) {
|
||||||
serviceID, err := trimID("service", serviceID)
|
serviceID, err := trimID("service", serviceID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return swarm.Service{}, nil, err
|
return swarm.Service{}, nil, err
|
||||||
|
3
vendor/github.com/docker/docker/client/service_list.go
generated
vendored
3
vendor/github.com/docker/docker/client/service_list.go
generated
vendored
@ -5,13 +5,12 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
|
||||||
"github.com/docker/docker/api/types/filters"
|
"github.com/docker/docker/api/types/filters"
|
||||||
"github.com/docker/docker/api/types/swarm"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ServiceList returns the list of services.
|
// ServiceList returns the list of services.
|
||||||
func (cli *Client) ServiceList(ctx context.Context, options types.ServiceListOptions) ([]swarm.Service, error) {
|
func (cli *Client) ServiceList(ctx context.Context, options swarm.ServiceListOptions) ([]swarm.Service, error) {
|
||||||
query := url.Values{}
|
query := url.Values{}
|
||||||
|
|
||||||
if options.Filters.Len() > 0 {
|
if options.Filters.Len() > 0 {
|
||||||
|
3
vendor/github.com/docker/docker/client/service_update.go
generated
vendored
3
vendor/github.com/docker/docker/client/service_update.go
generated
vendored
@ -6,7 +6,6 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
|
||||||
"github.com/docker/docker/api/types/registry"
|
"github.com/docker/docker/api/types/registry"
|
||||||
"github.com/docker/docker/api/types/swarm"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
"github.com/docker/docker/api/types/versions"
|
"github.com/docker/docker/api/types/versions"
|
||||||
@ -15,7 +14,7 @@ import (
|
|||||||
// ServiceUpdate updates a Service. The version number is required to avoid conflicting writes.
|
// ServiceUpdate updates a Service. The version number is required to avoid conflicting writes.
|
||||||
// It should be the value as set *before* the update. You can find this value in the Meta field
|
// It should be the value as set *before* the update. You can find this value in the Meta field
|
||||||
// of swarm.Service, which can be found using ServiceInspectWithRaw.
|
// of swarm.Service, which can be found using ServiceInspectWithRaw.
|
||||||
func (cli *Client) ServiceUpdate(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options types.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error) {
|
func (cli *Client) ServiceUpdate(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options swarm.ServiceUpdateOptions) (swarm.ServiceUpdateResponse, error) {
|
||||||
serviceID, err := trimID("service", serviceID)
|
serviceID, err := trimID("service", serviceID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return swarm.ServiceUpdateResponse{}, err
|
return swarm.ServiceUpdateResponse{}, err
|
||||||
|
8
vendor/github.com/docker/docker/client/swarm_get_unlock_key.go
generated
vendored
8
vendor/github.com/docker/docker/client/swarm_get_unlock_key.go
generated
vendored
@ -4,18 +4,18 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
)
|
)
|
||||||
|
|
||||||
// SwarmGetUnlockKey retrieves the swarm's unlock key.
|
// SwarmGetUnlockKey retrieves the swarm's unlock key.
|
||||||
func (cli *Client) SwarmGetUnlockKey(ctx context.Context) (types.SwarmUnlockKeyResponse, error) {
|
func (cli *Client) SwarmGetUnlockKey(ctx context.Context) (swarm.UnlockKeyResponse, error) {
|
||||||
resp, err := cli.get(ctx, "/swarm/unlockkey", nil, nil)
|
resp, err := cli.get(ctx, "/swarm/unlockkey", nil, nil)
|
||||||
defer ensureReaderClosed(resp)
|
defer ensureReaderClosed(resp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return types.SwarmUnlockKeyResponse{}, err
|
return swarm.UnlockKeyResponse{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
var response types.SwarmUnlockKeyResponse
|
var response swarm.UnlockKeyResponse
|
||||||
err = json.NewDecoder(resp.Body).Decode(&response)
|
err = json.NewDecoder(resp.Body).Decode(&response)
|
||||||
return response, err
|
return response, err
|
||||||
}
|
}
|
||||||
|
3
vendor/github.com/docker/docker/client/task_list.go
generated
vendored
3
vendor/github.com/docker/docker/client/task_list.go
generated
vendored
@ -5,13 +5,12 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
|
||||||
"github.com/docker/docker/api/types"
|
|
||||||
"github.com/docker/docker/api/types/filters"
|
"github.com/docker/docker/api/types/filters"
|
||||||
"github.com/docker/docker/api/types/swarm"
|
"github.com/docker/docker/api/types/swarm"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TaskList returns the list of tasks.
|
// TaskList returns the list of tasks.
|
||||||
func (cli *Client) TaskList(ctx context.Context, options types.TaskListOptions) ([]swarm.Task, error) {
|
func (cli *Client) TaskList(ctx context.Context, options swarm.TaskListOptions) ([]swarm.Task, error) {
|
||||||
query := url.Values{}
|
query := url.Values{}
|
||||||
|
|
||||||
if options.Filters.Len() > 0 {
|
if options.Filters.Len() > 0 {
|
||||||
|
4
vendor/github.com/docker/docker/client/utils.go
generated
vendored
4
vendor/github.com/docker/docker/client/utils.go
generated
vendored
@ -6,8 +6,8 @@ import (
|
|||||||
"net/url"
|
"net/url"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
cerrdefs "github.com/containerd/errdefs"
|
||||||
"github.com/docker/docker/api/types/filters"
|
"github.com/docker/docker/api/types/filters"
|
||||||
"github.com/docker/docker/errdefs"
|
|
||||||
"github.com/docker/docker/internal/lazyregexp"
|
"github.com/docker/docker/internal/lazyregexp"
|
||||||
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
|
||||||
)
|
)
|
||||||
@ -90,7 +90,7 @@ func encodePlatforms(platform ...ocispec.Platform) ([]string, error) {
|
|||||||
func encodePlatform(platform *ocispec.Platform) (string, error) {
|
func encodePlatform(platform *ocispec.Platform) (string, error) {
|
||||||
p, err := json.Marshal(platform)
|
p, err := json.Marshal(platform)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", errdefs.InvalidParameter(fmt.Errorf("invalid platform: %v", err))
|
return "", fmt.Errorf("%w: invalid platform: %v", cerrdefs.ErrInvalidArgument, err)
|
||||||
}
|
}
|
||||||
return string(p), nil
|
return string(p), nil
|
||||||
}
|
}
|
||||||
|
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
@ -61,7 +61,7 @@ github.com/docker/distribution/registry/client/transport
|
|||||||
github.com/docker/distribution/registry/storage/cache
|
github.com/docker/distribution/registry/storage/cache
|
||||||
github.com/docker/distribution/registry/storage/cache/memory
|
github.com/docker/distribution/registry/storage/cache/memory
|
||||||
github.com/docker/distribution/uuid
|
github.com/docker/distribution/uuid
|
||||||
# github.com/docker/docker v28.1.2-0.20250519114040-7937f0846c13+incompatible
|
# github.com/docker/docker v28.2.0-rc.1.0.20250519201520-8601b22f5db5+incompatible
|
||||||
## explicit
|
## explicit
|
||||||
github.com/docker/docker/api
|
github.com/docker/docker/api
|
||||||
github.com/docker/docker/api/types
|
github.com/docker/docker/api/types
|
||||||
|
Loading…
x
Reference in New Issue
Block a user