Merge pull request #4134 from thaJeztah/update_golangci_lint

update golangci-lint to v1.52.2
This commit is contained in:
Sebastiaan van Stijn 2023-03-30 19:55:22 +02:00 committed by GitHub
commit adbfa8208a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
49 changed files with 238 additions and 262 deletions

View File

@ -14,21 +14,21 @@ type fakeClient struct {
checkpointListFunc func(container string, options types.CheckpointListOptions) ([]types.Checkpoint, error) checkpointListFunc func(container string, options types.CheckpointListOptions) ([]types.Checkpoint, error)
} }
func (cli *fakeClient) CheckpointCreate(ctx context.Context, container string, options types.CheckpointCreateOptions) error { func (cli *fakeClient) CheckpointCreate(_ context.Context, container string, options types.CheckpointCreateOptions) error {
if cli.checkpointCreateFunc != nil { if cli.checkpointCreateFunc != nil {
return cli.checkpointCreateFunc(container, options) return cli.checkpointCreateFunc(container, options)
} }
return nil return nil
} }
func (cli *fakeClient) CheckpointDelete(ctx context.Context, container string, options types.CheckpointDeleteOptions) error { func (cli *fakeClient) CheckpointDelete(_ context.Context, container string, options types.CheckpointDeleteOptions) error {
if cli.checkpointDeleteFunc != nil { if cli.checkpointDeleteFunc != nil {
return cli.checkpointDeleteFunc(container, options) return cli.checkpointDeleteFunc(container, options)
} }
return nil return nil
} }
func (cli *fakeClient) CheckpointList(ctx context.Context, container string, options types.CheckpointListOptions) ([]types.Checkpoint, error) { func (cli *fakeClient) CheckpointList(_ context.Context, container string, options types.CheckpointListOptions) ([]types.Checkpoint, error) {
if cli.checkpointListFunc != nil { if cli.checkpointListFunc != nil {
return cli.checkpointListFunc(container, options) return cli.checkpointListFunc(container, options)
} }

View File

@ -94,6 +94,6 @@ func NetworkNames(dockerCli command.Cli) ValidArgsFn {
} }
// NoComplete is used for commands where there's no relevant completion // NoComplete is used for commands where there's no relevant completion
func NoComplete(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { func NoComplete(*cobra.Command, []string, string) ([]string, cobra.ShellCompDirective) {
return nil, cobra.ShellCompDirectiveNoFileComp return nil, cobra.ShellCompDirectiveNoFileComp
} }

View File

@ -10,34 +10,34 @@ import (
type fakeClient struct { type fakeClient struct {
client.Client client.Client
configCreateFunc func(swarm.ConfigSpec) (types.ConfigCreateResponse, error) configCreateFunc func(context.Context, swarm.ConfigSpec) (types.ConfigCreateResponse, error)
configInspectFunc func(string) (swarm.Config, []byte, error) configInspectFunc func(context.Context, string) (swarm.Config, []byte, error)
configListFunc func(types.ConfigListOptions) ([]swarm.Config, error) configListFunc func(context.Context, types.ConfigListOptions) ([]swarm.Config, error)
configRemoveFunc func(string) error configRemoveFunc func(string) error
} }
func (c *fakeClient) ConfigCreate(ctx context.Context, spec swarm.ConfigSpec) (types.ConfigCreateResponse, error) { func (c *fakeClient) ConfigCreate(ctx context.Context, spec swarm.ConfigSpec) (types.ConfigCreateResponse, error) {
if c.configCreateFunc != nil { if c.configCreateFunc != nil {
return c.configCreateFunc(spec) return c.configCreateFunc(ctx, spec)
} }
return types.ConfigCreateResponse{}, nil return types.ConfigCreateResponse{}, nil
} }
func (c *fakeClient) ConfigInspectWithRaw(ctx context.Context, id string) (swarm.Config, []byte, error) { func (c *fakeClient) ConfigInspectWithRaw(ctx context.Context, id string) (swarm.Config, []byte, error) {
if c.configInspectFunc != nil { if c.configInspectFunc != nil {
return c.configInspectFunc(id) return c.configInspectFunc(ctx, id)
} }
return swarm.Config{}, nil, nil return swarm.Config{}, nil, nil
} }
func (c *fakeClient) ConfigList(ctx context.Context, options types.ConfigListOptions) ([]swarm.Config, error) { func (c *fakeClient) ConfigList(ctx context.Context, options types.ConfigListOptions) ([]swarm.Config, error) {
if c.configListFunc != nil { if c.configListFunc != nil {
return c.configListFunc(options) return c.configListFunc(ctx, options)
} }
return []swarm.Config{}, nil return []swarm.Config{}, nil
} }
func (c *fakeClient) ConfigRemove(ctx context.Context, name string) error { func (c *fakeClient) ConfigRemove(_ context.Context, name string) error {
if c.configRemoveFunc != nil { if c.configRemoveFunc != nil {
return c.configRemoveFunc(name) return c.configRemoveFunc(name)
} }

View File

@ -1,6 +1,7 @@
package config package config
import ( import (
"context"
"io" "io"
"os" "os"
"path/filepath" "path/filepath"
@ -22,7 +23,7 @@ const configDataFile = "config-create-with-name.golden"
func TestConfigCreateErrors(t *testing.T) { func TestConfigCreateErrors(t *testing.T) {
testCases := []struct { testCases := []struct {
args []string args []string
configCreateFunc func(swarm.ConfigSpec) (types.ConfigCreateResponse, error) configCreateFunc func(context.Context, swarm.ConfigSpec) (types.ConfigCreateResponse, error)
expectedError string expectedError string
}{ }{
{ {
@ -35,7 +36,7 @@ func TestConfigCreateErrors(t *testing.T) {
}, },
{ {
args: []string{"name", filepath.Join("testdata", configDataFile)}, args: []string{"name", filepath.Join("testdata", configDataFile)},
configCreateFunc: func(configSpec swarm.ConfigSpec) (types.ConfigCreateResponse, error) { configCreateFunc: func(_ context.Context, configSpec swarm.ConfigSpec) (types.ConfigCreateResponse, error) {
return types.ConfigCreateResponse{}, errors.Errorf("error creating config") return types.ConfigCreateResponse{}, errors.Errorf("error creating config")
}, },
expectedError: "error creating config", expectedError: "error creating config",
@ -57,7 +58,7 @@ func TestConfigCreateWithName(t *testing.T) {
name := "foo" name := "foo"
var actual []byte var actual []byte
cli := test.NewFakeCli(&fakeClient{ cli := test.NewFakeCli(&fakeClient{
configCreateFunc: func(spec swarm.ConfigSpec) (types.ConfigCreateResponse, error) { configCreateFunc: func(_ context.Context, spec swarm.ConfigSpec) (types.ConfigCreateResponse, error) {
if spec.Name != name { if spec.Name != name {
return types.ConfigCreateResponse{}, errors.Errorf("expected name %q, got %q", name, spec.Name) return types.ConfigCreateResponse{}, errors.Errorf("expected name %q, got %q", name, spec.Name)
} }
@ -96,7 +97,7 @@ func TestConfigCreateWithLabels(t *testing.T) {
} }
cli := test.NewFakeCli(&fakeClient{ cli := test.NewFakeCli(&fakeClient{
configCreateFunc: func(spec swarm.ConfigSpec) (types.ConfigCreateResponse, error) { configCreateFunc: func(_ context.Context, spec swarm.ConfigSpec) (types.ConfigCreateResponse, error) {
if !reflect.DeepEqual(spec, expected) { if !reflect.DeepEqual(spec, expected) {
return types.ConfigCreateResponse{}, errors.Errorf("expected %+v, got %+v", expected, spec) return types.ConfigCreateResponse{}, errors.Errorf("expected %+v, got %+v", expected, spec)
} }
@ -122,7 +123,7 @@ func TestConfigCreateWithTemplatingDriver(t *testing.T) {
name := "foo" name := "foo"
cli := test.NewFakeCli(&fakeClient{ cli := test.NewFakeCli(&fakeClient{
configCreateFunc: func(spec swarm.ConfigSpec) (types.ConfigCreateResponse, error) { configCreateFunc: func(_ context.Context, spec swarm.ConfigSpec) (types.ConfigCreateResponse, error) {
if spec.Name != name { if spec.Name != name {
return types.ConfigCreateResponse{}, errors.Errorf("expected name %q, got %q", name, spec.Name) return types.ConfigCreateResponse{}, errors.Errorf("expected name %q, got %q", name, spec.Name)
} }

View File

@ -1,6 +1,7 @@
package config package config
import ( import (
"context"
"fmt" "fmt"
"io" "io"
"testing" "testing"
@ -18,7 +19,7 @@ func TestConfigInspectErrors(t *testing.T) {
testCases := []struct { testCases := []struct {
args []string args []string
flags map[string]string flags map[string]string
configInspectFunc func(configID string) (swarm.Config, []byte, error) configInspectFunc func(_ context.Context, configID string) (swarm.Config, []byte, error)
expectedError string expectedError string
}{ }{
{ {
@ -26,7 +27,7 @@ func TestConfigInspectErrors(t *testing.T) {
}, },
{ {
args: []string{"foo"}, args: []string{"foo"},
configInspectFunc: func(configID string) (swarm.Config, []byte, error) { configInspectFunc: func(_ context.Context, configID string) (swarm.Config, []byte, error) {
return swarm.Config{}, nil, errors.Errorf("error while inspecting the config") return swarm.Config{}, nil, errors.Errorf("error while inspecting the config")
}, },
expectedError: "error while inspecting the config", expectedError: "error while inspecting the config",
@ -40,7 +41,7 @@ func TestConfigInspectErrors(t *testing.T) {
}, },
{ {
args: []string{"foo", "bar"}, args: []string{"foo", "bar"},
configInspectFunc: func(configID string) (swarm.Config, []byte, error) { configInspectFunc: func(_ context.Context, configID string) (swarm.Config, []byte, error) {
if configID == "foo" { if configID == "foo" {
return *Config(ConfigName("foo")), nil, nil return *Config(ConfigName("foo")), nil, nil
} }
@ -68,12 +69,12 @@ func TestConfigInspectWithoutFormat(t *testing.T) {
testCases := []struct { testCases := []struct {
name string name string
args []string args []string
configInspectFunc func(configID string) (swarm.Config, []byte, error) configInspectFunc func(_ context.Context, configID string) (swarm.Config, []byte, error)
}{ }{
{ {
name: "single-config", name: "single-config",
args: []string{"foo"}, args: []string{"foo"},
configInspectFunc: func(name string) (swarm.Config, []byte, error) { configInspectFunc: func(_ context.Context, name string) (swarm.Config, []byte, error) {
if name != "foo" { if name != "foo" {
return swarm.Config{}, nil, errors.Errorf("Invalid name, expected %s, got %s", "foo", name) return swarm.Config{}, nil, errors.Errorf("Invalid name, expected %s, got %s", "foo", name)
} }
@ -83,7 +84,7 @@ func TestConfigInspectWithoutFormat(t *testing.T) {
{ {
name: "multiple-configs-with-labels", name: "multiple-configs-with-labels",
args: []string{"foo", "bar"}, args: []string{"foo", "bar"},
configInspectFunc: func(name string) (swarm.Config, []byte, error) { configInspectFunc: func(_ context.Context, name string) (swarm.Config, []byte, error) {
return *Config(ConfigID("ID-"+name), ConfigName(name), ConfigLabels(map[string]string{ return *Config(ConfigID("ID-"+name), ConfigName(name), ConfigLabels(map[string]string{
"label1": "label-foo", "label1": "label-foo",
})), nil, nil })), nil, nil
@ -100,7 +101,7 @@ func TestConfigInspectWithoutFormat(t *testing.T) {
} }
func TestConfigInspectWithFormat(t *testing.T) { func TestConfigInspectWithFormat(t *testing.T) {
configInspectFunc := func(name string) (swarm.Config, []byte, error) { configInspectFunc := func(_ context.Context, name string) (swarm.Config, []byte, error) {
return *Config(ConfigName("foo"), ConfigLabels(map[string]string{ return *Config(ConfigName("foo"), ConfigLabels(map[string]string{
"label1": "label-foo", "label1": "label-foo",
})), nil, nil })), nil, nil
@ -109,7 +110,7 @@ func TestConfigInspectWithFormat(t *testing.T) {
name string name string
format string format string
args []string args []string
configInspectFunc func(name string) (swarm.Config, []byte, error) configInspectFunc func(_ context.Context, name string) (swarm.Config, []byte, error)
}{ }{
{ {
name: "simple-template", name: "simple-template",
@ -139,11 +140,11 @@ func TestConfigInspectWithFormat(t *testing.T) {
func TestConfigInspectPretty(t *testing.T) { func TestConfigInspectPretty(t *testing.T) {
testCases := []struct { testCases := []struct {
name string name string
configInspectFunc func(string) (swarm.Config, []byte, error) configInspectFunc func(context.Context, string) (swarm.Config, []byte, error)
}{ }{
{ {
name: "simple", name: "simple",
configInspectFunc: func(id string) (swarm.Config, []byte, error) { configInspectFunc: func(_ context.Context, id string) (swarm.Config, []byte, error) {
return *Config( return *Config(
ConfigLabels(map[string]string{ ConfigLabels(map[string]string{
"lbl1": "value1", "lbl1": "value1",

View File

@ -1,6 +1,7 @@
package config package config
import ( import (
"context"
"io" "io"
"testing" "testing"
"time" "time"
@ -19,7 +20,7 @@ import (
func TestConfigListErrors(t *testing.T) { func TestConfigListErrors(t *testing.T) {
testCases := []struct { testCases := []struct {
args []string args []string
configListFunc func(types.ConfigListOptions) ([]swarm.Config, error) configListFunc func(context.Context, types.ConfigListOptions) ([]swarm.Config, error)
expectedError string expectedError string
}{ }{
{ {
@ -27,7 +28,7 @@ func TestConfigListErrors(t *testing.T) {
expectedError: "accepts no argument", expectedError: "accepts no argument",
}, },
{ {
configListFunc: func(options types.ConfigListOptions) ([]swarm.Config, error) { configListFunc: func(_ context.Context, options types.ConfigListOptions) ([]swarm.Config, error) {
return []swarm.Config{}, errors.Errorf("error listing configs") return []swarm.Config{}, errors.Errorf("error listing configs")
}, },
expectedError: "error listing configs", expectedError: "error listing configs",
@ -47,7 +48,7 @@ func TestConfigListErrors(t *testing.T) {
func TestConfigList(t *testing.T) { func TestConfigList(t *testing.T) {
cli := test.NewFakeCli(&fakeClient{ cli := test.NewFakeCli(&fakeClient{
configListFunc: func(options types.ConfigListOptions) ([]swarm.Config, error) { configListFunc: func(_ context.Context, options types.ConfigListOptions) ([]swarm.Config, error) {
return []swarm.Config{ return []swarm.Config{
*Config(ConfigID("ID-1-foo"), *Config(ConfigID("ID-1-foo"),
ConfigName("1-foo"), ConfigName("1-foo"),
@ -77,7 +78,7 @@ func TestConfigList(t *testing.T) {
func TestConfigListWithQuietOption(t *testing.T) { func TestConfigListWithQuietOption(t *testing.T) {
cli := test.NewFakeCli(&fakeClient{ cli := test.NewFakeCli(&fakeClient{
configListFunc: func(options types.ConfigListOptions) ([]swarm.Config, error) { configListFunc: func(_ context.Context, options types.ConfigListOptions) ([]swarm.Config, error) {
return []swarm.Config{ return []swarm.Config{
*Config(ConfigID("ID-foo"), ConfigName("foo")), *Config(ConfigID("ID-foo"), ConfigName("foo")),
*Config(ConfigID("ID-bar"), ConfigName("bar"), ConfigLabels(map[string]string{ *Config(ConfigID("ID-bar"), ConfigName("bar"), ConfigLabels(map[string]string{
@ -94,7 +95,7 @@ func TestConfigListWithQuietOption(t *testing.T) {
func TestConfigListWithConfigFormat(t *testing.T) { func TestConfigListWithConfigFormat(t *testing.T) {
cli := test.NewFakeCli(&fakeClient{ cli := test.NewFakeCli(&fakeClient{
configListFunc: func(options types.ConfigListOptions) ([]swarm.Config, error) { configListFunc: func(_ context.Context, options types.ConfigListOptions) ([]swarm.Config, error) {
return []swarm.Config{ return []swarm.Config{
*Config(ConfigID("ID-foo"), ConfigName("foo")), *Config(ConfigID("ID-foo"), ConfigName("foo")),
*Config(ConfigID("ID-bar"), ConfigName("bar"), ConfigLabels(map[string]string{ *Config(ConfigID("ID-bar"), ConfigName("bar"), ConfigLabels(map[string]string{
@ -113,7 +114,7 @@ func TestConfigListWithConfigFormat(t *testing.T) {
func TestConfigListWithFormat(t *testing.T) { func TestConfigListWithFormat(t *testing.T) {
cli := test.NewFakeCli(&fakeClient{ cli := test.NewFakeCli(&fakeClient{
configListFunc: func(options types.ConfigListOptions) ([]swarm.Config, error) { configListFunc: func(_ context.Context, options types.ConfigListOptions) ([]swarm.Config, error) {
return []swarm.Config{ return []swarm.Config{
*Config(ConfigID("ID-foo"), ConfigName("foo")), *Config(ConfigID("ID-foo"), ConfigName("foo")),
*Config(ConfigID("ID-bar"), ConfigName("bar"), ConfigLabels(map[string]string{ *Config(ConfigID("ID-bar"), ConfigName("bar"), ConfigLabels(map[string]string{
@ -130,7 +131,7 @@ func TestConfigListWithFormat(t *testing.T) {
func TestConfigListWithFilter(t *testing.T) { func TestConfigListWithFilter(t *testing.T) {
cli := test.NewFakeCli(&fakeClient{ cli := test.NewFakeCli(&fakeClient{
configListFunc: func(options types.ConfigListOptions) ([]swarm.Config, error) { configListFunc: func(_ context.Context, options types.ConfigListOptions) ([]swarm.Config, error) {
assert.Check(t, is.Equal("foo", options.Filters.Get("name")[0])) assert.Check(t, is.Equal("foo", options.Filters.Get("name")[0]))
assert.Check(t, is.Equal("lbl1=Label-bar", options.Filters.Get("label")[0])) assert.Check(t, is.Equal("lbl1=Label-bar", options.Filters.Get("label")[0]))
return []swarm.Config{ return []swarm.Config{

View File

@ -64,7 +64,7 @@ func (f *fakeClient) ContainerExecInspect(_ context.Context, execID string) (typ
return types.ContainerExecInspect{}, nil return types.ContainerExecInspect{}, nil
} }
func (f *fakeClient) ContainerExecStart(ctx context.Context, execID string, config types.ExecStartCheck) error { func (f *fakeClient) ContainerExecStart(context.Context, string, types.ExecStartCheck) error {
return nil return nil
} }
@ -89,7 +89,7 @@ func (f *fakeClient) ContainerRemove(ctx context.Context, container string, opti
return nil return nil
} }
func (f *fakeClient) ImageCreate(ctx context.Context, parentReference string, options types.ImageCreateOptions) (io.ReadCloser, error) { func (f *fakeClient) ImageCreate(_ context.Context, parentReference string, options types.ImageCreateOptions) (io.ReadCloser, error) {
if f.imageCreateFunc != nil { if f.imageCreateFunc != nil {
return f.imageCreateFunc(parentReference, options) return f.imageCreateFunc(parentReference, options)
} }

View File

@ -75,6 +75,6 @@ func runPrune(dockerCli command.Cli, options pruneOptions) (spaceReclaimed uint6
// RunPrune calls the Container Prune API // RunPrune calls the Container Prune API
// This returns the amount of space reclaimed and a detailed output string // This returns the amount of space reclaimed and a detailed output string
func RunPrune(dockerCli command.Cli, all bool, filter opts.FilterOpt) (uint64, string, error) { func RunPrune(dockerCli command.Cli, _ bool, filter opts.FilterOpt) (uint64, string, error) {
return runPrune(dockerCli, pruneOptions{force: true, filter: filter}) return runPrune(dockerCli, pruneOptions{force: true, filter: filter})
} }

View File

@ -173,11 +173,11 @@ func runContainer(dockerCli command.Cli, opts *runOptions, copts *containerOptio
dockerCli.ConfigFile().DetachKeys = opts.detachKeys dockerCli.ConfigFile().DetachKeys = opts.detachKeys
} }
close, err := attachContainer(ctx, dockerCli, &errCh, config, createResponse.ID) closeFn, err := attachContainer(ctx, dockerCli, &errCh, config, createResponse.ID)
if err != nil { if err != nil {
return err return err
} }
defer close() defer closeFn()
} }
statusChan := waitExitOrRemoved(ctx, dockerCli, createResponse.ID, copts.autoRemove) statusChan := waitExitOrRemoved(ctx, dockerCli, createResponse.ID, copts.autoRemove)

View File

@ -118,10 +118,7 @@ func createNewContext(o *CreateOptions, cli command.Cli, s store.Writer) error {
if err := s.CreateOrUpdate(contextMetadata); err != nil { if err := s.CreateOrUpdate(contextMetadata); err != nil {
return err return err
} }
if err := s.ResetTLSMaterial(o.Name, &contextTLSData); err != nil { return s.ResetTLSMaterial(o.Name, &contextTLSData)
return err
}
return nil
} }
func checkContextNameForCreation(s store.Reader, name string) error { func checkContextNameForCreation(s store.Reader, name string) error {

View File

@ -14,14 +14,14 @@ type fakeClient struct {
serviceInspectFunc func(string) (swarm.Service, []byte, error) serviceInspectFunc func(string) (swarm.Service, []byte, error)
} }
func (cli *fakeClient) NodeInspectWithRaw(ctx context.Context, nodeID string) (swarm.Node, []byte, error) { func (cli *fakeClient) NodeInspectWithRaw(_ context.Context, nodeID string) (swarm.Node, []byte, error) {
if cli.nodeInspectFunc != nil { if cli.nodeInspectFunc != nil {
return cli.nodeInspectFunc(nodeID) return cli.nodeInspectFunc(nodeID)
} }
return swarm.Node{}, []byte{}, nil return swarm.Node{}, []byte{}, nil
} }
func (cli *fakeClient) ServiceInspectWithRaw(ctx context.Context, serviceID string, options types.ServiceInspectOptions) (swarm.Service, []byte, error) { func (cli *fakeClient) ServiceInspectWithRaw(_ context.Context, serviceID string, _ types.ServiceInspectOptions) (swarm.Service, []byte, error) {
if cli.serviceInspectFunc != nil { if cli.serviceInspectFunc != nil {
return cli.serviceInspectFunc(serviceID) return cli.serviceInspectFunc(serviceID)
} }

View File

@ -18,7 +18,7 @@ import (
const dockerfileContents = "FROM busybox" const dockerfileContents = "FROM busybox"
func prepareEmpty(t *testing.T) string { func prepareEmpty(_ *testing.T) string {
return "" return ""
} }

View File

@ -87,7 +87,7 @@ func (cli *fakeClient) ImageLoad(_ context.Context, input io.Reader, quiet bool)
return types.ImageLoadResponse{}, nil return types.ImageLoadResponse{}, nil
} }
func (cli *fakeClient) ImageList(ctx context.Context, options types.ImageListOptions) ([]types.ImageSummary, error) { func (cli *fakeClient) ImageList(_ context.Context, options types.ImageListOptions) ([]types.ImageSummary, error) {
if cli.imageListFunc != nil { if cli.imageListFunc != nil {
return cli.imageListFunc(options) return cli.imageListFunc(options)
} }

View File

@ -52,6 +52,6 @@ func (c *fakeClient) NetworkRemove(ctx context.Context, networkID string) error
return nil return nil
} }
func (c *fakeClient) NetworkInspectWithRaw(ctx context.Context, network string, options types.NetworkInspectOptions) (types.NetworkResource, []byte, error) { func (c *fakeClient) NetworkInspectWithRaw(context.Context, string, types.NetworkInspectOptions) (types.NetworkResource, []byte, error) {
return types.NetworkResource{}, nil, nil return types.NetworkResource{}, nil, nil
} }

View File

@ -70,7 +70,7 @@ func runPrune(dockerCli command.Cli, options pruneOptions) (output string, err e
// RunPrune calls the Network Prune API // RunPrune calls the Network Prune API
// This returns the amount of space reclaimed and a detailed output string // This returns the amount of space reclaimed and a detailed output string
func RunPrune(dockerCli command.Cli, all bool, filter opts.FilterOpt) (uint64, string, error) { func RunPrune(dockerCli command.Cli, _ bool, filter opts.FilterOpt) (uint64, string, error) {
output, err := runPrune(dockerCli, pruneOptions{force: true, filter: filter}) output, err := runPrune(dockerCli, pruneOptions{force: true, filter: filter})
return 0, output, err return 0, output, err
} }

View File

@ -20,49 +20,49 @@ type fakeClient struct {
serviceInspectFunc func(ctx context.Context, serviceID string, opts types.ServiceInspectOptions) (swarm.Service, []byte, error) serviceInspectFunc func(ctx context.Context, serviceID string, opts types.ServiceInspectOptions) (swarm.Service, []byte, error)
} }
func (cli *fakeClient) NodeInspectWithRaw(ctx context.Context, ref string) (swarm.Node, []byte, error) { func (cli *fakeClient) NodeInspectWithRaw(context.Context, string) (swarm.Node, []byte, error) {
if cli.nodeInspectFunc != nil { if cli.nodeInspectFunc != nil {
return cli.nodeInspectFunc() return cli.nodeInspectFunc()
} }
return swarm.Node{}, []byte{}, nil return swarm.Node{}, []byte{}, nil
} }
func (cli *fakeClient) NodeList(ctx context.Context, options types.NodeListOptions) ([]swarm.Node, error) { func (cli *fakeClient) NodeList(context.Context, types.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(ctx context.Context, nodeID string, options types.NodeRemoveOptions) error { func (cli *fakeClient) NodeRemove(context.Context, string, types.NodeRemoveOptions) error {
if cli.nodeRemoveFunc != nil { if cli.nodeRemoveFunc != nil {
return cli.nodeRemoveFunc() return cli.nodeRemoveFunc()
} }
return nil return nil
} }
func (cli *fakeClient) NodeUpdate(ctx context.Context, nodeID string, version swarm.Version, node swarm.NodeSpec) error { func (cli *fakeClient) NodeUpdate(_ context.Context, nodeID string, version swarm.Version, node swarm.NodeSpec) error {
if cli.nodeUpdateFunc != nil { if cli.nodeUpdateFunc != nil {
return cli.nodeUpdateFunc(nodeID, version, node) return cli.nodeUpdateFunc(nodeID, version, node)
} }
return nil return nil
} }
func (cli *fakeClient) Info(ctx context.Context) (types.Info, error) { func (cli *fakeClient) Info(context.Context) (types.Info, error) {
if cli.infoFunc != nil { if cli.infoFunc != nil {
return cli.infoFunc() return cli.infoFunc()
} }
return types.Info{}, nil return types.Info{}, nil
} }
func (cli *fakeClient) TaskInspectWithRaw(ctx context.Context, taskID string) (swarm.Task, []byte, error) { func (cli *fakeClient) TaskInspectWithRaw(_ context.Context, taskID string) (swarm.Task, []byte, error) {
if cli.taskInspectFunc != nil { if cli.taskInspectFunc != nil {
return cli.taskInspectFunc(taskID) return cli.taskInspectFunc(taskID)
} }
return swarm.Task{}, []byte{}, nil return swarm.Task{}, []byte{}, nil
} }
func (cli *fakeClient) TaskList(ctx context.Context, options types.TaskListOptions) ([]swarm.Task, error) { func (cli *fakeClient) TaskList(_ context.Context, options types.TaskListOptions) ([]swarm.Task, error) {
if cli.taskListFunc != nil { if cli.taskListFunc != nil {
return cli.taskListFunc(options) return cli.taskListFunc(options)
} }

View File

@ -20,42 +20,42 @@ type fakeClient struct {
pluginInspectFunc func(name string) (*types.Plugin, []byte, error) pluginInspectFunc func(name string) (*types.Plugin, []byte, error)
} }
func (c *fakeClient) PluginCreate(ctx context.Context, createContext io.Reader, createOptions types.PluginCreateOptions) error { func (c *fakeClient) PluginCreate(_ context.Context, createContext io.Reader, createOptions types.PluginCreateOptions) error {
if c.pluginCreateFunc != nil { if c.pluginCreateFunc != nil {
return c.pluginCreateFunc(createContext, createOptions) return c.pluginCreateFunc(createContext, createOptions)
} }
return nil return nil
} }
func (c *fakeClient) PluginEnable(ctx context.Context, name string, enableOptions types.PluginEnableOptions) error { func (c *fakeClient) PluginEnable(_ context.Context, name string, enableOptions types.PluginEnableOptions) error {
if c.pluginEnableFunc != nil { if c.pluginEnableFunc != nil {
return c.pluginEnableFunc(name, enableOptions) return c.pluginEnableFunc(name, enableOptions)
} }
return nil return nil
} }
func (c *fakeClient) PluginDisable(context context.Context, name string, disableOptions types.PluginDisableOptions) error { func (c *fakeClient) PluginDisable(_ context.Context, name string, disableOptions types.PluginDisableOptions) error {
if c.pluginDisableFunc != nil { if c.pluginDisableFunc != nil {
return c.pluginDisableFunc(name, disableOptions) return c.pluginDisableFunc(name, disableOptions)
} }
return nil return nil
} }
func (c *fakeClient) PluginRemove(context context.Context, name string, removeOptions types.PluginRemoveOptions) error { func (c *fakeClient) PluginRemove(_ context.Context, name string, removeOptions types.PluginRemoveOptions) error {
if c.pluginRemoveFunc != nil { if c.pluginRemoveFunc != nil {
return c.pluginRemoveFunc(name, removeOptions) return c.pluginRemoveFunc(name, removeOptions)
} }
return nil return nil
} }
func (c *fakeClient) PluginInstall(context context.Context, name string, installOptions types.PluginInstallOptions) (io.ReadCloser, error) { func (c *fakeClient) PluginInstall(_ context.Context, name string, installOptions types.PluginInstallOptions) (io.ReadCloser, error) {
if c.pluginInstallFunc != nil { if c.pluginInstallFunc != nil {
return c.pluginInstallFunc(name, installOptions) return c.pluginInstallFunc(name, installOptions)
} }
return nil, nil return nil, nil
} }
func (c *fakeClient) PluginList(context context.Context, filter filters.Args) (types.PluginsListResponse, error) { func (c *fakeClient) PluginList(_ context.Context, filter filters.Args) (types.PluginsListResponse, error) {
if c.pluginListFunc != nil { if c.pluginListFunc != nil {
return c.pluginListFunc(filter) return c.pluginListFunc(filter)
} }
@ -63,7 +63,7 @@ func (c *fakeClient) PluginList(context context.Context, filter filters.Args) (t
return types.PluginsListResponse{}, nil return types.PluginsListResponse{}, nil
} }
func (c *fakeClient) PluginInspectWithRaw(ctx context.Context, name string) (*types.Plugin, []byte, error) { func (c *fakeClient) PluginInspectWithRaw(_ context.Context, name string) (*types.Plugin, []byte, error) {
if c.pluginInspectFunc != nil { if c.pluginInspectFunc != nil {
return c.pluginInspectFunc(name) return c.pluginInspectFunc(name)
} }
@ -71,6 +71,6 @@ func (c *fakeClient) PluginInspectWithRaw(ctx context.Context, name string) (*ty
return nil, nil, nil return nil, nil, nil
} }
func (c *fakeClient) Info(ctx context.Context) (types.Info, error) { func (c *fakeClient) Info(context.Context) (types.Info, error) {
return types.Info{}, nil return types.Info{}, nil
} }

View File

@ -34,11 +34,11 @@ type fakeClient struct {
client.Client client.Client
} }
func (c fakeClient) Info(ctx context.Context) (types.Info, error) { func (c fakeClient) Info(context.Context) (types.Info, error) {
return types.Info{}, nil return types.Info{}, nil
} }
func (c fakeClient) RegistryLogin(ctx context.Context, auth types.AuthConfig) (registrytypes.AuthenticateOKBody, error) { func (c fakeClient) RegistryLogin(_ context.Context, auth types.AuthConfig) (registrytypes.AuthenticateOKBody, error) {
if auth.Password == expiredPassword { if auth.Password == expiredPassword {
return registrytypes.AuthenticateOKBody{}, fmt.Errorf("Invalid Username or Password") return registrytypes.AuthenticateOKBody{}, fmt.Errorf("Invalid Username or Password")
} }

View File

@ -10,36 +10,36 @@ import (
type fakeClient struct { type fakeClient struct {
client.Client client.Client
secretCreateFunc func(swarm.SecretSpec) (types.SecretCreateResponse, error) secretCreateFunc func(context.Context, swarm.SecretSpec) (types.SecretCreateResponse, error)
secretInspectFunc func(string) (swarm.Secret, []byte, error) secretInspectFunc func(context.Context, string) (swarm.Secret, []byte, error)
secretListFunc func(types.SecretListOptions) ([]swarm.Secret, error) secretListFunc func(context.Context, types.SecretListOptions) ([]swarm.Secret, error)
secretRemoveFunc func(string) error secretRemoveFunc func(context.Context, string) error
} }
func (c *fakeClient) SecretCreate(ctx context.Context, spec swarm.SecretSpec) (types.SecretCreateResponse, error) { func (c *fakeClient) SecretCreate(ctx context.Context, spec swarm.SecretSpec) (types.SecretCreateResponse, error) {
if c.secretCreateFunc != nil { if c.secretCreateFunc != nil {
return c.secretCreateFunc(spec) return c.secretCreateFunc(ctx, spec)
} }
return types.SecretCreateResponse{}, nil return types.SecretCreateResponse{}, nil
} }
func (c *fakeClient) SecretInspectWithRaw(ctx context.Context, id string) (swarm.Secret, []byte, error) { func (c *fakeClient) SecretInspectWithRaw(ctx context.Context, id string) (swarm.Secret, []byte, error) {
if c.secretInspectFunc != nil { if c.secretInspectFunc != nil {
return c.secretInspectFunc(id) return c.secretInspectFunc(ctx, id)
} }
return swarm.Secret{}, nil, nil return swarm.Secret{}, nil, nil
} }
func (c *fakeClient) SecretList(ctx context.Context, options types.SecretListOptions) ([]swarm.Secret, error) { func (c *fakeClient) SecretList(ctx context.Context, options types.SecretListOptions) ([]swarm.Secret, error) {
if c.secretListFunc != nil { if c.secretListFunc != nil {
return c.secretListFunc(options) return c.secretListFunc(ctx, options)
} }
return []swarm.Secret{}, nil return []swarm.Secret{}, nil
} }
func (c *fakeClient) SecretRemove(ctx context.Context, name string) error { func (c *fakeClient) SecretRemove(ctx context.Context, name string) error {
if c.secretRemoveFunc != nil { if c.secretRemoveFunc != nil {
return c.secretRemoveFunc(name) return c.secretRemoveFunc(ctx, name)
} }
return nil return nil
} }

View File

@ -1,6 +1,7 @@
package secret package secret
import ( import (
"context"
"io" "io"
"os" "os"
"path/filepath" "path/filepath"
@ -21,7 +22,7 @@ const secretDataFile = "secret-create-with-name.golden"
func TestSecretCreateErrors(t *testing.T) { func TestSecretCreateErrors(t *testing.T) {
testCases := []struct { testCases := []struct {
args []string args []string
secretCreateFunc func(swarm.SecretSpec) (types.SecretCreateResponse, error) secretCreateFunc func(context.Context, swarm.SecretSpec) (types.SecretCreateResponse, error)
expectedError string expectedError string
}{ }{
{ {
@ -34,7 +35,7 @@ func TestSecretCreateErrors(t *testing.T) {
}, },
{ {
args: []string{"name", filepath.Join("testdata", secretDataFile)}, args: []string{"name", filepath.Join("testdata", secretDataFile)},
secretCreateFunc: func(secretSpec swarm.SecretSpec) (types.SecretCreateResponse, error) { secretCreateFunc: func(_ context.Context, secretSpec swarm.SecretSpec) (types.SecretCreateResponse, error) {
return types.SecretCreateResponse{}, errors.Errorf("error creating secret") return types.SecretCreateResponse{}, errors.Errorf("error creating secret")
}, },
expectedError: "error creating secret", expectedError: "error creating secret",
@ -66,7 +67,7 @@ func TestSecretCreateWithName(t *testing.T) {
} }
cli := test.NewFakeCli(&fakeClient{ cli := test.NewFakeCli(&fakeClient{
secretCreateFunc: func(spec swarm.SecretSpec) (types.SecretCreateResponse, error) { secretCreateFunc: func(_ context.Context, spec swarm.SecretSpec) (types.SecretCreateResponse, error) {
if !reflect.DeepEqual(spec, expected) { if !reflect.DeepEqual(spec, expected) {
return types.SecretCreateResponse{}, errors.Errorf("expected %+v, got %+v", expected, spec) return types.SecretCreateResponse{}, errors.Errorf("expected %+v, got %+v", expected, spec)
} }
@ -89,7 +90,7 @@ func TestSecretCreateWithDriver(t *testing.T) {
name := "foo" name := "foo"
cli := test.NewFakeCli(&fakeClient{ cli := test.NewFakeCli(&fakeClient{
secretCreateFunc: func(spec swarm.SecretSpec) (types.SecretCreateResponse, error) { secretCreateFunc: func(_ context.Context, spec swarm.SecretSpec) (types.SecretCreateResponse, error) {
if spec.Name != name { if spec.Name != name {
return types.SecretCreateResponse{}, errors.Errorf("expected name %q, got %q", name, spec.Name) return types.SecretCreateResponse{}, errors.Errorf("expected name %q, got %q", name, spec.Name)
} }
@ -118,7 +119,7 @@ func TestSecretCreateWithTemplatingDriver(t *testing.T) {
name := "foo" name := "foo"
cli := test.NewFakeCli(&fakeClient{ cli := test.NewFakeCli(&fakeClient{
secretCreateFunc: func(spec swarm.SecretSpec) (types.SecretCreateResponse, error) { secretCreateFunc: func(_ context.Context, spec swarm.SecretSpec) (types.SecretCreateResponse, error) {
if spec.Name != name { if spec.Name != name {
return types.SecretCreateResponse{}, errors.Errorf("expected name %q, got %q", name, spec.Name) return types.SecretCreateResponse{}, errors.Errorf("expected name %q, got %q", name, spec.Name)
} }
@ -148,7 +149,7 @@ func TestSecretCreateWithLabels(t *testing.T) {
name := "foo" name := "foo"
cli := test.NewFakeCli(&fakeClient{ cli := test.NewFakeCli(&fakeClient{
secretCreateFunc: func(spec swarm.SecretSpec) (types.SecretCreateResponse, error) { secretCreateFunc: func(_ context.Context, spec swarm.SecretSpec) (types.SecretCreateResponse, error) {
if spec.Name != name { if spec.Name != name {
return types.SecretCreateResponse{}, errors.Errorf("expected name %q, got %q", name, spec.Name) return types.SecretCreateResponse{}, errors.Errorf("expected name %q, got %q", name, spec.Name)
} }

View File

@ -1,6 +1,7 @@
package secret package secret
import ( import (
"context"
"fmt" "fmt"
"io" "io"
"testing" "testing"
@ -18,7 +19,7 @@ func TestSecretInspectErrors(t *testing.T) {
testCases := []struct { testCases := []struct {
args []string args []string
flags map[string]string flags map[string]string
secretInspectFunc func(secretID string) (swarm.Secret, []byte, error) secretInspectFunc func(ctx context.Context, secretID string) (swarm.Secret, []byte, error)
expectedError string expectedError string
}{ }{
{ {
@ -26,7 +27,7 @@ func TestSecretInspectErrors(t *testing.T) {
}, },
{ {
args: []string{"foo"}, args: []string{"foo"},
secretInspectFunc: func(secretID string) (swarm.Secret, []byte, error) { secretInspectFunc: func(_ context.Context, secretID string) (swarm.Secret, []byte, error) {
return swarm.Secret{}, nil, errors.Errorf("error while inspecting the secret") return swarm.Secret{}, nil, errors.Errorf("error while inspecting the secret")
}, },
expectedError: "error while inspecting the secret", expectedError: "error while inspecting the secret",
@ -40,7 +41,7 @@ func TestSecretInspectErrors(t *testing.T) {
}, },
{ {
args: []string{"foo", "bar"}, args: []string{"foo", "bar"},
secretInspectFunc: func(secretID string) (swarm.Secret, []byte, error) { secretInspectFunc: func(_ context.Context, secretID string) (swarm.Secret, []byte, error) {
if secretID == "foo" { if secretID == "foo" {
return *Secret(SecretName("foo")), nil, nil return *Secret(SecretName("foo")), nil, nil
} }
@ -68,12 +69,12 @@ func TestSecretInspectWithoutFormat(t *testing.T) {
testCases := []struct { testCases := []struct {
name string name string
args []string args []string
secretInspectFunc func(secretID string) (swarm.Secret, []byte, error) secretInspectFunc func(ctx context.Context, secretID string) (swarm.Secret, []byte, error)
}{ }{
{ {
name: "single-secret", name: "single-secret",
args: []string{"foo"}, args: []string{"foo"},
secretInspectFunc: func(name string) (swarm.Secret, []byte, error) { secretInspectFunc: func(_ context.Context, name string) (swarm.Secret, []byte, error) {
if name != "foo" { if name != "foo" {
return swarm.Secret{}, nil, errors.Errorf("Invalid name, expected %s, got %s", "foo", name) return swarm.Secret{}, nil, errors.Errorf("Invalid name, expected %s, got %s", "foo", name)
} }
@ -83,7 +84,7 @@ func TestSecretInspectWithoutFormat(t *testing.T) {
{ {
name: "multiple-secrets-with-labels", name: "multiple-secrets-with-labels",
args: []string{"foo", "bar"}, args: []string{"foo", "bar"},
secretInspectFunc: func(name string) (swarm.Secret, []byte, error) { secretInspectFunc: func(_ context.Context, name string) (swarm.Secret, []byte, error) {
return *Secret(SecretID("ID-"+name), SecretName(name), SecretLabels(map[string]string{ return *Secret(SecretID("ID-"+name), SecretName(name), SecretLabels(map[string]string{
"label1": "label-foo", "label1": "label-foo",
})), nil, nil })), nil, nil
@ -102,7 +103,7 @@ func TestSecretInspectWithoutFormat(t *testing.T) {
} }
func TestSecretInspectWithFormat(t *testing.T) { func TestSecretInspectWithFormat(t *testing.T) {
secretInspectFunc := func(name string) (swarm.Secret, []byte, error) { secretInspectFunc := func(_ context.Context, name string) (swarm.Secret, []byte, error) {
return *Secret(SecretName("foo"), SecretLabels(map[string]string{ return *Secret(SecretName("foo"), SecretLabels(map[string]string{
"label1": "label-foo", "label1": "label-foo",
})), nil, nil })), nil, nil
@ -111,7 +112,7 @@ func TestSecretInspectWithFormat(t *testing.T) {
name string name string
format string format string
args []string args []string
secretInspectFunc func(name string) (swarm.Secret, []byte, error) secretInspectFunc func(_ context.Context, name string) (swarm.Secret, []byte, error)
}{ }{
{ {
name: "simple-template", name: "simple-template",
@ -141,11 +142,11 @@ func TestSecretInspectWithFormat(t *testing.T) {
func TestSecretInspectPretty(t *testing.T) { func TestSecretInspectPretty(t *testing.T) {
testCases := []struct { testCases := []struct {
name string name string
secretInspectFunc func(string) (swarm.Secret, []byte, error) secretInspectFunc func(context.Context, string) (swarm.Secret, []byte, error)
}{ }{
{ {
name: "simple", name: "simple",
secretInspectFunc: func(id string) (swarm.Secret, []byte, error) { secretInspectFunc: func(_ context.Context, id string) (swarm.Secret, []byte, error) {
return *Secret( return *Secret(
SecretLabels(map[string]string{ SecretLabels(map[string]string{
"lbl1": "value1", "lbl1": "value1",

View File

@ -1,6 +1,7 @@
package secret package secret
import ( import (
"context"
"io" "io"
"testing" "testing"
"time" "time"
@ -19,7 +20,7 @@ import (
func TestSecretListErrors(t *testing.T) { func TestSecretListErrors(t *testing.T) {
testCases := []struct { testCases := []struct {
args []string args []string
secretListFunc func(types.SecretListOptions) ([]swarm.Secret, error) secretListFunc func(context.Context, types.SecretListOptions) ([]swarm.Secret, error)
expectedError string expectedError string
}{ }{
{ {
@ -27,7 +28,7 @@ func TestSecretListErrors(t *testing.T) {
expectedError: "accepts no argument", expectedError: "accepts no argument",
}, },
{ {
secretListFunc: func(options types.SecretListOptions) ([]swarm.Secret, error) { secretListFunc: func(_ context.Context, options types.SecretListOptions) ([]swarm.Secret, error) {
return []swarm.Secret{}, errors.Errorf("error listing secrets") return []swarm.Secret{}, errors.Errorf("error listing secrets")
}, },
expectedError: "error listing secrets", expectedError: "error listing secrets",
@ -47,7 +48,7 @@ func TestSecretListErrors(t *testing.T) {
func TestSecretList(t *testing.T) { func TestSecretList(t *testing.T) {
cli := test.NewFakeCli(&fakeClient{ cli := test.NewFakeCli(&fakeClient{
secretListFunc: func(options types.SecretListOptions) ([]swarm.Secret, error) { secretListFunc: func(_ context.Context, options types.SecretListOptions) ([]swarm.Secret, error) {
return []swarm.Secret{ return []swarm.Secret{
*Secret(SecretID("ID-1-foo"), *Secret(SecretID("ID-1-foo"),
SecretName("1-foo"), SecretName("1-foo"),
@ -79,7 +80,7 @@ func TestSecretList(t *testing.T) {
func TestSecretListWithQuietOption(t *testing.T) { func TestSecretListWithQuietOption(t *testing.T) {
cli := test.NewFakeCli(&fakeClient{ cli := test.NewFakeCli(&fakeClient{
secretListFunc: func(options types.SecretListOptions) ([]swarm.Secret, error) { secretListFunc: func(_ context.Context, options types.SecretListOptions) ([]swarm.Secret, error) {
return []swarm.Secret{ return []swarm.Secret{
*Secret(SecretID("ID-foo"), SecretName("foo")), *Secret(SecretID("ID-foo"), SecretName("foo")),
*Secret(SecretID("ID-bar"), SecretName("bar"), SecretLabels(map[string]string{ *Secret(SecretID("ID-bar"), SecretName("bar"), SecretLabels(map[string]string{
@ -96,7 +97,7 @@ func TestSecretListWithQuietOption(t *testing.T) {
func TestSecretListWithConfigFormat(t *testing.T) { func TestSecretListWithConfigFormat(t *testing.T) {
cli := test.NewFakeCli(&fakeClient{ cli := test.NewFakeCli(&fakeClient{
secretListFunc: func(options types.SecretListOptions) ([]swarm.Secret, error) { secretListFunc: func(_ context.Context, options types.SecretListOptions) ([]swarm.Secret, error) {
return []swarm.Secret{ return []swarm.Secret{
*Secret(SecretID("ID-foo"), SecretName("foo")), *Secret(SecretID("ID-foo"), SecretName("foo")),
*Secret(SecretID("ID-bar"), SecretName("bar"), SecretLabels(map[string]string{ *Secret(SecretID("ID-bar"), SecretName("bar"), SecretLabels(map[string]string{
@ -115,7 +116,7 @@ func TestSecretListWithConfigFormat(t *testing.T) {
func TestSecretListWithFormat(t *testing.T) { func TestSecretListWithFormat(t *testing.T) {
cli := test.NewFakeCli(&fakeClient{ cli := test.NewFakeCli(&fakeClient{
secretListFunc: func(options types.SecretListOptions) ([]swarm.Secret, error) { secretListFunc: func(_ context.Context, options types.SecretListOptions) ([]swarm.Secret, error) {
return []swarm.Secret{ return []swarm.Secret{
*Secret(SecretID("ID-foo"), SecretName("foo")), *Secret(SecretID("ID-foo"), SecretName("foo")),
*Secret(SecretID("ID-bar"), SecretName("bar"), SecretLabels(map[string]string{ *Secret(SecretID("ID-bar"), SecretName("bar"), SecretLabels(map[string]string{
@ -132,7 +133,7 @@ func TestSecretListWithFormat(t *testing.T) {
func TestSecretListWithFilter(t *testing.T) { func TestSecretListWithFilter(t *testing.T) {
cli := test.NewFakeCli(&fakeClient{ cli := test.NewFakeCli(&fakeClient{
secretListFunc: func(options types.SecretListOptions) ([]swarm.Secret, error) { secretListFunc: func(_ context.Context, options types.SecretListOptions) ([]swarm.Secret, error) {
assert.Check(t, is.Equal("foo", options.Filters.Get("name")[0]), "foo") assert.Check(t, is.Equal("foo", options.Filters.Get("name")[0]), "foo")
assert.Check(t, is.Equal("lbl1=Label-bar", options.Filters.Get("label")[0])) assert.Check(t, is.Equal("lbl1=Label-bar", options.Filters.Get("label")[0]))
return []swarm.Secret{ return []swarm.Secret{

View File

@ -1,6 +1,7 @@
package secret package secret
import ( import (
"context"
"io" "io"
"strings" "strings"
"testing" "testing"
@ -14,7 +15,7 @@ import (
func TestSecretRemoveErrors(t *testing.T) { func TestSecretRemoveErrors(t *testing.T) {
testCases := []struct { testCases := []struct {
args []string args []string
secretRemoveFunc func(string) error secretRemoveFunc func(context.Context, string) error
expectedError string expectedError string
}{ }{
{ {
@ -23,7 +24,7 @@ func TestSecretRemoveErrors(t *testing.T) {
}, },
{ {
args: []string{"foo"}, args: []string{"foo"},
secretRemoveFunc: func(name string) error { secretRemoveFunc: func(_ context.Context, name string) error {
return errors.Errorf("error removing secret") return errors.Errorf("error removing secret")
}, },
expectedError: "error removing secret", expectedError: "error removing secret",
@ -45,7 +46,7 @@ func TestSecretRemoveWithName(t *testing.T) {
names := []string{"foo", "bar"} names := []string{"foo", "bar"}
var removedSecrets []string var removedSecrets []string
cli := test.NewFakeCli(&fakeClient{ cli := test.NewFakeCli(&fakeClient{
secretRemoveFunc: func(name string) error { secretRemoveFunc: func(_ context.Context, name string) error {
removedSecrets = append(removedSecrets, name) removedSecrets = append(removedSecrets, name)
return nil return nil
}, },
@ -62,7 +63,7 @@ func TestSecretRemoveContinueAfterError(t *testing.T) {
var removedSecrets []string var removedSecrets []string
cli := test.NewFakeCli(&fakeClient{ cli := test.NewFakeCli(&fakeClient{
secretRemoveFunc: func(name string) error { secretRemoveFunc: func(_ context.Context, name string) error {
removedSecrets = append(removedSecrets, name) removedSecrets = append(removedSecrets, name)
if name == "foo" { if name == "foo" {
return errors.Errorf("error removing secret: %s", name) return errors.Errorf("error removing secret: %s", name)

View File

@ -414,7 +414,7 @@ type globalProgressUpdater struct {
done bool done bool
} }
func (u *globalProgressUpdater) update(service swarm.Service, tasks []swarm.Task, activeNodes map[string]struct{}, rollback bool) (bool, error) { func (u *globalProgressUpdater) update(_ swarm.Service, tasks []swarm.Task, activeNodes map[string]struct{}, rollback bool) (bool, error) {
tasksByNode := u.tasksByNode(tasks) tasksByNode := u.tasksByNode(tasks)
// We don't have perfect knowledge of how many nodes meet the // We don't have perfect knowledge of how many nodes meet the

View File

@ -504,23 +504,23 @@ type secretAPIClientMock struct {
listResult []swarm.Secret listResult []swarm.Secret
} }
func (s secretAPIClientMock) SecretList(ctx context.Context, options types.SecretListOptions) ([]swarm.Secret, error) { func (s secretAPIClientMock) SecretList(context.Context, types.SecretListOptions) ([]swarm.Secret, error) {
return s.listResult, nil return s.listResult, nil
} }
func (s secretAPIClientMock) SecretCreate(ctx context.Context, secret swarm.SecretSpec) (types.SecretCreateResponse, error) { func (s secretAPIClientMock) SecretCreate(context.Context, swarm.SecretSpec) (types.SecretCreateResponse, error) {
return types.SecretCreateResponse{}, nil return types.SecretCreateResponse{}, nil
} }
func (s secretAPIClientMock) SecretRemove(ctx context.Context, id string) error { func (s secretAPIClientMock) SecretRemove(context.Context, string) error {
return nil return nil
} }
func (s secretAPIClientMock) SecretInspectWithRaw(ctx context.Context, name string) (swarm.Secret, []byte, error) { func (s secretAPIClientMock) SecretInspectWithRaw(context.Context, string) (swarm.Secret, []byte, error) {
return swarm.Secret{}, []byte{}, nil return swarm.Secret{}, []byte{}, nil
} }
func (s secretAPIClientMock) SecretUpdate(ctx context.Context, id string, version swarm.Version, secret swarm.SecretSpec) error { func (s secretAPIClientMock) SecretUpdate(context.Context, string, swarm.Version, swarm.SecretSpec) error {
return nil return nil
} }

View File

@ -43,7 +43,7 @@ type fakeClient struct {
configRemoveFunc func(configID string) error configRemoveFunc func(configID string) error
} }
func (cli *fakeClient) ServerVersion(ctx context.Context) (types.Version, error) { func (cli *fakeClient) ServerVersion(context.Context) (types.Version, error) {
return types.Version{ return types.Version{
Version: "docker-dev", Version: "docker-dev",
APIVersion: api.DefaultVersion, APIVersion: api.DefaultVersion,
@ -54,7 +54,7 @@ func (cli *fakeClient) ClientVersion() string {
return cli.version return cli.version
} }
func (cli *fakeClient) ServiceList(ctx context.Context, options types.ServiceListOptions) ([]swarm.Service, error) { func (cli *fakeClient) ServiceList(_ context.Context, options types.ServiceListOptions) ([]swarm.Service, error) {
if cli.serviceListFunc != nil { if cli.serviceListFunc != nil {
return cli.serviceListFunc(options) return cli.serviceListFunc(options)
} }
@ -69,7 +69,7 @@ func (cli *fakeClient) ServiceList(ctx context.Context, options types.ServiceLis
return servicesList, nil return servicesList, nil
} }
func (cli *fakeClient) NetworkList(ctx context.Context, options types.NetworkListOptions) ([]types.NetworkResource, error) { func (cli *fakeClient) NetworkList(_ context.Context, options types.NetworkListOptions) ([]types.NetworkResource, error) {
if cli.networkListFunc != nil { if cli.networkListFunc != nil {
return cli.networkListFunc(options) return cli.networkListFunc(options)
} }
@ -84,7 +84,7 @@ func (cli *fakeClient) NetworkList(ctx context.Context, options types.NetworkLis
return networksList, nil return networksList, nil
} }
func (cli *fakeClient) SecretList(ctx context.Context, options types.SecretListOptions) ([]swarm.Secret, error) { func (cli *fakeClient) SecretList(_ context.Context, options types.SecretListOptions) ([]swarm.Secret, error) {
if cli.secretListFunc != nil { if cli.secretListFunc != nil {
return cli.secretListFunc(options) return cli.secretListFunc(options)
} }
@ -99,7 +99,7 @@ func (cli *fakeClient) SecretList(ctx context.Context, options types.SecretListO
return secretsList, nil return secretsList, nil
} }
func (cli *fakeClient) ConfigList(ctx context.Context, options types.ConfigListOptions) ([]swarm.Config, error) { func (cli *fakeClient) ConfigList(_ context.Context, options types.ConfigListOptions) ([]swarm.Config, error) {
if cli.configListFunc != nil { if cli.configListFunc != nil {
return cli.configListFunc(options) return cli.configListFunc(options)
} }
@ -114,28 +114,28 @@ func (cli *fakeClient) ConfigList(ctx context.Context, options types.ConfigListO
return configsList, nil return configsList, nil
} }
func (cli *fakeClient) TaskList(ctx context.Context, options types.TaskListOptions) ([]swarm.Task, error) { func (cli *fakeClient) TaskList(_ context.Context, options types.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(ctx context.Context, options types.NodeListOptions) ([]swarm.Node, error) { func (cli *fakeClient) NodeList(_ context.Context, options types.NodeListOptions) ([]swarm.Node, error) {
if cli.nodeListFunc != nil { if cli.nodeListFunc != nil {
return cli.nodeListFunc(options) return cli.nodeListFunc(options)
} }
return []swarm.Node{}, nil return []swarm.Node{}, nil
} }
func (cli *fakeClient) NodeInspectWithRaw(ctx context.Context, ref string) (swarm.Node, []byte, error) { func (cli *fakeClient) NodeInspectWithRaw(_ context.Context, ref string) (swarm.Node, []byte, error) {
if cli.nodeInspectWithRaw != nil { if cli.nodeInspectWithRaw != nil {
return cli.nodeInspectWithRaw(ref) return cli.nodeInspectWithRaw(ref)
} }
return swarm.Node{}, nil, nil return swarm.Node{}, nil, nil
} }
func (cli *fakeClient) ServiceUpdate(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options types.ServiceUpdateOptions) (types.ServiceUpdateResponse, error) { func (cli *fakeClient) ServiceUpdate(_ context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options types.ServiceUpdateOptions) (types.ServiceUpdateResponse, error) {
if cli.serviceUpdateFunc != nil { if cli.serviceUpdateFunc != nil {
return cli.serviceUpdateFunc(serviceID, version, service, options) return cli.serviceUpdateFunc(serviceID, version, service, options)
} }
@ -143,7 +143,7 @@ func (cli *fakeClient) ServiceUpdate(ctx context.Context, serviceID string, vers
return types.ServiceUpdateResponse{}, nil return types.ServiceUpdateResponse{}, nil
} }
func (cli *fakeClient) ServiceRemove(ctx context.Context, serviceID string) error { func (cli *fakeClient) ServiceRemove(_ context.Context, serviceID string) error {
if cli.serviceRemoveFunc != nil { if cli.serviceRemoveFunc != nil {
return cli.serviceRemoveFunc(serviceID) return cli.serviceRemoveFunc(serviceID)
} }
@ -152,7 +152,7 @@ func (cli *fakeClient) ServiceRemove(ctx context.Context, serviceID string) erro
return nil return nil
} }
func (cli *fakeClient) NetworkRemove(ctx context.Context, networkID string) error { func (cli *fakeClient) NetworkRemove(_ context.Context, networkID string) error {
if cli.networkRemoveFunc != nil { if cli.networkRemoveFunc != nil {
return cli.networkRemoveFunc(networkID) return cli.networkRemoveFunc(networkID)
} }
@ -161,7 +161,7 @@ func (cli *fakeClient) NetworkRemove(ctx context.Context, networkID string) erro
return nil return nil
} }
func (cli *fakeClient) SecretRemove(ctx context.Context, secretID string) error { func (cli *fakeClient) SecretRemove(_ context.Context, secretID string) error {
if cli.secretRemoveFunc != nil { if cli.secretRemoveFunc != nil {
return cli.secretRemoveFunc(secretID) return cli.secretRemoveFunc(secretID)
} }
@ -170,7 +170,7 @@ func (cli *fakeClient) SecretRemove(ctx context.Context, secretID string) error
return nil return nil
} }
func (cli *fakeClient) ConfigRemove(ctx context.Context, configID string) error { func (cli *fakeClient) ConfigRemove(_ context.Context, configID string) error {
if cli.configRemoveFunc != nil { if cli.configRemoveFunc != nil {
return cli.configRemoveFunc(configID) return cli.configRemoveFunc(configID)
} }
@ -179,7 +179,7 @@ func (cli *fakeClient) ConfigRemove(ctx context.Context, configID string) error
return nil return nil
} }
func (cli *fakeClient) ServiceInspectWithRaw(ctx context.Context, serviceID string, opts types.ServiceInspectOptions) (swarm.Service, []byte, error) { func (cli *fakeClient) ServiceInspectWithRaw(_ context.Context, serviceID string, _ types.ServiceInspectOptions) (swarm.Service, []byte, error) {
return swarm.Service{ return swarm.Service{
ID: serviceID, ID: serviceID,
Spec: swarm.ServiceSpec{ Spec: swarm.ServiceSpec{

View File

@ -28,7 +28,7 @@ func newDeployCommand(dockerCli command.Cli) *cobra.Command {
if err != nil { if err != nil {
return err return err
} }
return RunDeploy(dockerCli, cmd.Flags(), config, opts) return swarm.RunDeploy(dockerCli, opts, config)
}, },
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
return completeNames(dockerCli)(cmd, args, toComplete) return completeNames(dockerCli)(cmd, args, toComplete)
@ -47,7 +47,9 @@ func newDeployCommand(dockerCli command.Cli) *cobra.Command {
return cmd return cmd
} }
// RunDeploy performs a stack deploy against the specified swarm cluster // RunDeploy performs a stack deploy against the specified swarm cluster.
func RunDeploy(dockerCli command.Cli, flags *pflag.FlagSet, config *composetypes.Config, opts options.Deploy) error { //
// Deprecated: use [swarm.RunDeploy] instead.
func RunDeploy(dockerCli command.Cli, _ *pflag.FlagSet, config *composetypes.Config, opts options.Deploy) error {
return swarm.RunDeploy(dockerCli, opts, config) return swarm.RunDeploy(dockerCli, opts, config)
} }

View File

@ -23,7 +23,7 @@ func newListCommand(dockerCli command.Cli) *cobra.Command {
Short: "List stacks", Short: "List stacks",
Args: cli.NoArgs, Args: cli.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
return RunList(cmd, dockerCli, opts) return RunList(dockerCli, opts)
}, },
ValidArgsFunction: completion.NoComplete, ValidArgsFunction: completion.NoComplete,
} }
@ -34,24 +34,24 @@ func newListCommand(dockerCli command.Cli) *cobra.Command {
} }
// RunList performs a stack list against the specified swarm cluster // RunList performs a stack list against the specified swarm cluster
func RunList(cmd *cobra.Command, dockerCli command.Cli, opts options.List) error { func RunList(dockerCli command.Cli, opts options.List) error {
stacks := []*formatter.Stack{}
ss, err := swarm.GetStacks(dockerCli) ss, err := swarm.GetStacks(dockerCli)
if err != nil { if err != nil {
return err return err
} }
stacks := make([]*formatter.Stack, 0, len(ss))
stacks = append(stacks, ss...) stacks = append(stacks, ss...)
return format(dockerCli, opts, stacks) return format(dockerCli, opts, stacks)
} }
func format(dockerCli command.Cli, opts options.List, stacks []*formatter.Stack) error { func format(dockerCli command.Cli, opts options.List, stacks []*formatter.Stack) error {
format := formatter.Format(opts.Format) fmt := formatter.Format(opts.Format)
if format == "" || format == formatter.TableFormatKey { if fmt == "" || fmt == formatter.TableFormatKey {
format = formatter.SwarmStackTableFormat fmt = formatter.SwarmStackTableFormat
} }
stackCtx := formatter.Context{ stackCtx := formatter.Context{
Output: dockerCli.Out(), Output: dockerCli.Out(),
Format: format, Format: fmt,
} }
sort.Slice(stacks, func(i, j int) bool { sort.Slice(stacks, func(i, j int) bool {
return sortorder.NaturalLess(stacks[i].Name, stacks[j].Name) || return sortorder.NaturalLess(stacks[i].Name, stacks[j].Name) ||

View File

@ -23,7 +23,7 @@ func newPsCommand(dockerCli command.Cli) *cobra.Command {
if err := validateStackName(opts.Namespace); err != nil { if err := validateStackName(opts.Namespace); err != nil {
return err return err
} }
return RunPs(dockerCli, cmd.Flags(), opts) return swarm.RunPS(dockerCli, opts)
}, },
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
return completeNames(dockerCli)(cmd, args, toComplete) return completeNames(dockerCli)(cmd, args, toComplete)
@ -38,7 +38,9 @@ func newPsCommand(dockerCli command.Cli) *cobra.Command {
return cmd return cmd
} }
// RunPs performs a stack ps against the specified swarm cluster // RunPs performs a stack ps against the specified swarm cluster.
func RunPs(dockerCli command.Cli, flags *pflag.FlagSet, opts options.PS) error { //
// Deprecated: use [swarm.RunPS] instead.
func RunPs(dockerCli command.Cli, _ *pflag.FlagSet, opts options.PS) error {
return swarm.RunPS(dockerCli, opts) return swarm.RunPS(dockerCli, opts)
} }

View File

@ -22,7 +22,7 @@ func newRemoveCommand(dockerCli command.Cli) *cobra.Command {
if err := validateStackNames(opts.Namespaces); err != nil { if err := validateStackNames(opts.Namespaces); err != nil {
return err return err
} }
return RunRemove(dockerCli, cmd.Flags(), opts) return swarm.RunRemove(dockerCli, opts)
}, },
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
return completeNames(dockerCli)(cmd, args, toComplete) return completeNames(dockerCli)(cmd, args, toComplete)
@ -31,7 +31,9 @@ func newRemoveCommand(dockerCli command.Cli) *cobra.Command {
return cmd return cmd
} }
// RunRemove performs a stack remove against the specified swarm cluster // RunRemove performs a stack remove against the specified swarm cluster.
func RunRemove(dockerCli command.Cli, flags *pflag.FlagSet, opts options.Remove) error { //
// Deprecated: use [swarm.RunRemove] instead.
func RunRemove(dockerCli command.Cli, _ *pflag.FlagSet, opts options.Remove) error {
return swarm.RunRemove(dockerCli, opts) return swarm.RunRemove(dockerCli, opts)
} }

View File

@ -30,7 +30,7 @@ func newServicesCommand(dockerCli command.Cli) *cobra.Command {
if err := validateStackName(opts.Namespace); err != nil { if err := validateStackName(opts.Namespace); err != nil {
return err return err
} }
return RunServices(dockerCli, cmd.Flags(), opts) return RunServices(dockerCli, opts)
}, },
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
return completeNames(dockerCli)(cmd, args, toComplete) return completeNames(dockerCli)(cmd, args, toComplete)
@ -44,16 +44,18 @@ func newServicesCommand(dockerCli command.Cli) *cobra.Command {
} }
// RunServices performs a stack services against the specified swarm cluster // RunServices performs a stack services against the specified swarm cluster
func RunServices(dockerCli command.Cli, flags *pflag.FlagSet, opts options.Services) error { func RunServices(dockerCli command.Cli, opts options.Services) error {
services, err := GetServices(dockerCli, flags, opts) services, err := swarm.GetServices(dockerCli, opts)
if err != nil { if err != nil {
return err return err
} }
return formatWrite(dockerCli, services, opts) return formatWrite(dockerCli, services, opts)
} }
// GetServices returns the services for the specified swarm cluster // GetServices returns the services for the specified swarm cluster.
func GetServices(dockerCli command.Cli, flags *pflag.FlagSet, opts options.Services) ([]swarmtypes.Service, error) { //
// Deprecated: use [swarm.GetServices] instead.
func GetServices(dockerCli command.Cli, _ *pflag.FlagSet, opts options.Services) ([]swarmtypes.Service, error) {
return swarm.GetServices(dockerCli, opts) return swarm.GetServices(dockerCli, opts)
} }

View File

@ -43,7 +43,7 @@ type fakeClient struct {
configRemoveFunc func(configID string) error configRemoveFunc func(configID string) error
} }
func (cli *fakeClient) ServerVersion(ctx context.Context) (types.Version, error) { func (cli *fakeClient) ServerVersion(context.Context) (types.Version, error) {
return types.Version{ return types.Version{
Version: "docker-dev", Version: "docker-dev",
APIVersion: api.DefaultVersion, APIVersion: api.DefaultVersion,
@ -54,7 +54,7 @@ func (cli *fakeClient) ClientVersion() string {
return cli.version return cli.version
} }
func (cli *fakeClient) ServiceList(ctx context.Context, options types.ServiceListOptions) ([]swarm.Service, error) { func (cli *fakeClient) ServiceList(_ context.Context, options types.ServiceListOptions) ([]swarm.Service, error) {
if cli.serviceListFunc != nil { if cli.serviceListFunc != nil {
return cli.serviceListFunc(options) return cli.serviceListFunc(options)
} }
@ -69,7 +69,7 @@ func (cli *fakeClient) ServiceList(ctx context.Context, options types.ServiceLis
return servicesList, nil return servicesList, nil
} }
func (cli *fakeClient) NetworkList(ctx context.Context, options types.NetworkListOptions) ([]types.NetworkResource, error) { func (cli *fakeClient) NetworkList(_ context.Context, options types.NetworkListOptions) ([]types.NetworkResource, error) {
if cli.networkListFunc != nil { if cli.networkListFunc != nil {
return cli.networkListFunc(options) return cli.networkListFunc(options)
} }
@ -84,7 +84,7 @@ func (cli *fakeClient) NetworkList(ctx context.Context, options types.NetworkLis
return networksList, nil return networksList, nil
} }
func (cli *fakeClient) SecretList(ctx context.Context, options types.SecretListOptions) ([]swarm.Secret, error) { func (cli *fakeClient) SecretList(_ context.Context, options types.SecretListOptions) ([]swarm.Secret, error) {
if cli.secretListFunc != nil { if cli.secretListFunc != nil {
return cli.secretListFunc(options) return cli.secretListFunc(options)
} }
@ -99,7 +99,7 @@ func (cli *fakeClient) SecretList(ctx context.Context, options types.SecretListO
return secretsList, nil return secretsList, nil
} }
func (cli *fakeClient) ConfigList(ctx context.Context, options types.ConfigListOptions) ([]swarm.Config, error) { func (cli *fakeClient) ConfigList(_ context.Context, options types.ConfigListOptions) ([]swarm.Config, error) {
if cli.configListFunc != nil { if cli.configListFunc != nil {
return cli.configListFunc(options) return cli.configListFunc(options)
} }
@ -114,28 +114,28 @@ func (cli *fakeClient) ConfigList(ctx context.Context, options types.ConfigListO
return configsList, nil return configsList, nil
} }
func (cli *fakeClient) TaskList(ctx context.Context, options types.TaskListOptions) ([]swarm.Task, error) { func (cli *fakeClient) TaskList(_ context.Context, options types.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(ctx context.Context, options types.NodeListOptions) ([]swarm.Node, error) { func (cli *fakeClient) NodeList(_ context.Context, options types.NodeListOptions) ([]swarm.Node, error) {
if cli.nodeListFunc != nil { if cli.nodeListFunc != nil {
return cli.nodeListFunc(options) return cli.nodeListFunc(options)
} }
return []swarm.Node{}, nil return []swarm.Node{}, nil
} }
func (cli *fakeClient) NodeInspectWithRaw(ctx context.Context, ref string) (swarm.Node, []byte, error) { func (cli *fakeClient) NodeInspectWithRaw(_ context.Context, ref string) (swarm.Node, []byte, error) {
if cli.nodeInspectWithRaw != nil { if cli.nodeInspectWithRaw != nil {
return cli.nodeInspectWithRaw(ref) return cli.nodeInspectWithRaw(ref)
} }
return swarm.Node{}, nil, nil return swarm.Node{}, nil, nil
} }
func (cli *fakeClient) ServiceUpdate(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options types.ServiceUpdateOptions) (types.ServiceUpdateResponse, error) { func (cli *fakeClient) ServiceUpdate(_ context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options types.ServiceUpdateOptions) (types.ServiceUpdateResponse, error) {
if cli.serviceUpdateFunc != nil { if cli.serviceUpdateFunc != nil {
return cli.serviceUpdateFunc(serviceID, version, service, options) return cli.serviceUpdateFunc(serviceID, version, service, options)
} }
@ -143,7 +143,7 @@ func (cli *fakeClient) ServiceUpdate(ctx context.Context, serviceID string, vers
return types.ServiceUpdateResponse{}, nil return types.ServiceUpdateResponse{}, nil
} }
func (cli *fakeClient) ServiceRemove(ctx context.Context, serviceID string) error { func (cli *fakeClient) ServiceRemove(_ context.Context, serviceID string) error {
if cli.serviceRemoveFunc != nil { if cli.serviceRemoveFunc != nil {
return cli.serviceRemoveFunc(serviceID) return cli.serviceRemoveFunc(serviceID)
} }
@ -152,7 +152,7 @@ func (cli *fakeClient) ServiceRemove(ctx context.Context, serviceID string) erro
return nil return nil
} }
func (cli *fakeClient) NetworkRemove(ctx context.Context, networkID string) error { func (cli *fakeClient) NetworkRemove(_ context.Context, networkID string) error {
if cli.networkRemoveFunc != nil { if cli.networkRemoveFunc != nil {
return cli.networkRemoveFunc(networkID) return cli.networkRemoveFunc(networkID)
} }
@ -161,7 +161,7 @@ func (cli *fakeClient) NetworkRemove(ctx context.Context, networkID string) erro
return nil return nil
} }
func (cli *fakeClient) SecretRemove(ctx context.Context, secretID string) error { func (cli *fakeClient) SecretRemove(_ context.Context, secretID string) error {
if cli.secretRemoveFunc != nil { if cli.secretRemoveFunc != nil {
return cli.secretRemoveFunc(secretID) return cli.secretRemoveFunc(secretID)
} }
@ -170,7 +170,7 @@ func (cli *fakeClient) SecretRemove(ctx context.Context, secretID string) error
return nil return nil
} }
func (cli *fakeClient) ConfigRemove(ctx context.Context, configID string) error { func (cli *fakeClient) ConfigRemove(_ context.Context, configID string) error {
if cli.configRemoveFunc != nil { if cli.configRemoveFunc != nil {
return cli.configRemoveFunc(configID) return cli.configRemoveFunc(configID)
} }

View File

@ -21,63 +21,63 @@ type fakeClient struct {
swarmUnlockFunc func(req swarm.UnlockRequest) error swarmUnlockFunc func(req swarm.UnlockRequest) error
} }
func (cli *fakeClient) Info(ctx context.Context) (types.Info, error) { func (cli *fakeClient) Info(context.Context) (types.Info, error) {
if cli.infoFunc != nil { if cli.infoFunc != nil {
return cli.infoFunc() return cli.infoFunc()
} }
return types.Info{}, nil return types.Info{}, nil
} }
func (cli *fakeClient) NodeInspectWithRaw(ctx context.Context, ref string) (swarm.Node, []byte, error) { func (cli *fakeClient) NodeInspectWithRaw(context.Context, string) (swarm.Node, []byte, error) {
if cli.nodeInspectFunc != nil { if cli.nodeInspectFunc != nil {
return cli.nodeInspectFunc() return cli.nodeInspectFunc()
} }
return swarm.Node{}, []byte{}, nil return swarm.Node{}, []byte{}, nil
} }
func (cli *fakeClient) SwarmInit(ctx context.Context, req swarm.InitRequest) (string, error) { func (cli *fakeClient) SwarmInit(context.Context, swarm.InitRequest) (string, error) {
if cli.swarmInitFunc != nil { if cli.swarmInitFunc != nil {
return cli.swarmInitFunc() return cli.swarmInitFunc()
} }
return "", nil return "", nil
} }
func (cli *fakeClient) SwarmInspect(ctx context.Context) (swarm.Swarm, error) { func (cli *fakeClient) SwarmInspect(context.Context) (swarm.Swarm, error) {
if cli.swarmInspectFunc != nil { if cli.swarmInspectFunc != nil {
return cli.swarmInspectFunc() return cli.swarmInspectFunc()
} }
return swarm.Swarm{}, nil return swarm.Swarm{}, nil
} }
func (cli *fakeClient) SwarmGetUnlockKey(ctx context.Context) (types.SwarmUnlockKeyResponse, error) { func (cli *fakeClient) SwarmGetUnlockKey(context.Context) (types.SwarmUnlockKeyResponse, error) {
if cli.swarmGetUnlockKeyFunc != nil { if cli.swarmGetUnlockKeyFunc != nil {
return cli.swarmGetUnlockKeyFunc() return cli.swarmGetUnlockKeyFunc()
} }
return types.SwarmUnlockKeyResponse{}, nil return types.SwarmUnlockKeyResponse{}, nil
} }
func (cli *fakeClient) SwarmJoin(ctx context.Context, req swarm.JoinRequest) error { func (cli *fakeClient) SwarmJoin(context.Context, swarm.JoinRequest) error {
if cli.swarmJoinFunc != nil { if cli.swarmJoinFunc != nil {
return cli.swarmJoinFunc() return cli.swarmJoinFunc()
} }
return nil return nil
} }
func (cli *fakeClient) SwarmLeave(ctx context.Context, force bool) error { func (cli *fakeClient) SwarmLeave(context.Context, bool) error {
if cli.swarmLeaveFunc != nil { if cli.swarmLeaveFunc != nil {
return cli.swarmLeaveFunc() return cli.swarmLeaveFunc()
} }
return nil return nil
} }
func (cli *fakeClient) SwarmUpdate(ctx context.Context, version swarm.Version, swarm swarm.Spec, flags swarm.UpdateFlags) error { func (cli *fakeClient) SwarmUpdate(_ context.Context, _ swarm.Version, swarm swarm.Spec, flags swarm.UpdateFlags) error {
if cli.swarmUpdateFunc != nil { if cli.swarmUpdateFunc != nil {
return cli.swarmUpdateFunc(swarm, flags) return cli.swarmUpdateFunc(swarm, flags)
} }
return nil return nil
} }
func (cli *fakeClient) SwarmUnlock(ctx context.Context, req swarm.UnlockRequest) error { func (cli *fakeClient) SwarmUnlock(_ context.Context, req swarm.UnlockRequest) error {
if cli.swarmUnlockFunc != nil { if cli.swarmUnlockFunc != nil {
return cli.swarmUnlockFunc(req) return cli.swarmUnlockFunc(req)
} }

View File

@ -10,7 +10,7 @@ import (
) )
// Helper function to set static slices // Helper function to set static slices
func getCIDR(ip net.IP, cidr *net.IPNet, err error) net.IPNet { func getCIDR(_ net.IP, cidr *net.IPNet, _ error) net.IPNet {
return *cidr return *cidr
} }

View File

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

View File

@ -27,15 +27,15 @@ type fakeClient struct {
apiclient.Client apiclient.Client
} }
func (c *fakeClient) Info(ctx context.Context) (types.Info, error) { func (c *fakeClient) Info(context.Context) (types.Info, error) {
return types.Info{}, nil return types.Info{}, nil
} }
func (c *fakeClient) ImageInspectWithRaw(ctx context.Context, imageID string) (types.ImageInspect, []byte, error) { func (c *fakeClient) ImageInspectWithRaw(context.Context, string) (types.ImageInspect, []byte, error) {
return types.ImageInspect{}, []byte{}, nil return types.ImageInspect{}, []byte{}, nil
} }
func (c *fakeClient) ImagePush(ctx context.Context, image string, options types.ImagePushOptions) (io.ReadCloser, error) { func (c *fakeClient) ImagePush(context.Context, string, types.ImagePushOptions) (io.ReadCloser, error) {
return &utils.NoopCloser{Reader: bytes.NewBuffer([]byte{})}, nil return &utils.NoopCloser{Reader: bytes.NewBuffer([]byte{})}, nil
} }

View File

@ -75,6 +75,6 @@ func runPrune(dockerCli command.Cli, options pruneOptions) (spaceReclaimed uint6
// RunPrune calls the Volume Prune API // RunPrune calls the Volume Prune API
// This returns the amount of space reclaimed and a detailed output string // This returns the amount of space reclaimed and a detailed output string
func RunPrune(dockerCli command.Cli, all bool, filter opts.FilterOpt) (uint64, string, error) { func RunPrune(dockerCli command.Cli, _ bool, filter opts.FilterOpt) (uint64, string, error) {
return runPrune(dockerCli, pruneOptions{force: true, filter: filter}) return runPrune(dockerCli, pruneOptions{force: true, filter: filter})
} }

View File

@ -110,7 +110,7 @@ func TestVolumePrunePromptNo(t *testing.T) {
} }
} }
func simplePruneFunc(args filters.Args) (types.VolumesPruneReport, error) { func simplePruneFunc(filters.Args) (types.VolumesPruneReport, error) {
return types.VolumesPruneReport{ return types.VolumesPruneReport{
VolumesDeleted: []string{ VolumesDeleted: []string{
"foo", "bar", "baz", "foo", "bar", "baz",

View File

@ -596,14 +596,14 @@ type fakeClient struct {
configListFunc func(types.ConfigListOptions) ([]swarm.Config, error) configListFunc func(types.ConfigListOptions) ([]swarm.Config, error)
} }
func (c *fakeClient) SecretList(ctx context.Context, options types.SecretListOptions) ([]swarm.Secret, error) { func (c *fakeClient) SecretList(_ context.Context, options types.SecretListOptions) ([]swarm.Secret, error) {
if c.secretListFunc != nil { if c.secretListFunc != nil {
return c.secretListFunc(options) return c.secretListFunc(options)
} }
return []swarm.Secret{}, nil return []swarm.Secret{}, nil
} }
func (c *fakeClient) ConfigList(ctx context.Context, options types.ConfigListOptions) ([]swarm.Config, error) { func (c *fakeClient) ConfigList(_ context.Context, options types.ConfigListOptions) ([]swarm.Config, error) {
if c.configListFunc != nil { if c.configListFunc != nil {
return c.configListFunc(options) return c.configListFunc(options)
} }

View File

@ -17,7 +17,7 @@ const (
type portsFormatChecker struct{} type portsFormatChecker struct{}
func (checker portsFormatChecker) IsFormat(input interface{}) bool { func (checker portsFormatChecker) IsFormat(_ interface{}) bool {
// TODO: implement this // TODO: implement this
return true return true
} }

View File

@ -186,7 +186,7 @@ func (c *mockNativeStore) GetAll() (map[string]types.AuthConfig, error) {
return c.authConfigs, nil return c.authConfigs, nil
} }
func (c *mockNativeStore) Store(authConfig types.AuthConfig) error { func (c *mockNativeStore) Store(_ types.AuthConfig) error {
return nil return nil
} }

View File

@ -32,7 +32,7 @@ import (
) )
// New returns net.Conn // New returns net.Conn
func New(ctx context.Context, cmd string, args ...string) (net.Conn, error) { func New(_ context.Context, cmd string, args ...string) (net.Conn, error) {
var ( var (
c commandConn c commandConn
err error err error

View File

@ -120,7 +120,7 @@ type existingTokenHandler struct {
token string token string
} }
func (th *existingTokenHandler) AuthorizeRequest(req *http.Request, params map[string]string) error { func (th *existingTokenHandler) AuthorizeRequest(req *http.Request, _ map[string]string) error {
req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", th.token)) req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", th.token))
return nil return nil
} }

View File

@ -82,16 +82,15 @@ type simpleCredentialStore struct {
auth types.AuthConfig auth types.AuthConfig
} }
func (scs simpleCredentialStore) Basic(u *url.URL) (string, string) { func (scs simpleCredentialStore) Basic(*url.URL) (string, string) {
return scs.auth.Username, scs.auth.Password return scs.auth.Username, scs.auth.Password
} }
func (scs simpleCredentialStore) RefreshToken(u *url.URL, service string) string { func (scs simpleCredentialStore) RefreshToken(*url.URL, string) string {
return scs.auth.IdentityToken return scs.auth.IdentityToken
} }
func (scs simpleCredentialStore) SetRefreshToken(*url.URL, string, string) { func (scs simpleCredentialStore) SetRefreshToken(*url.URL, string, string) {}
}
// GetNotaryRepository returns a NotaryRepository which stores all the // GetNotaryRepository returns a NotaryRepository which stores all the
// information needed to operate on a notary repository. // information needed to operate on a notary repository.

View File

@ -2,7 +2,7 @@
ARG GO_VERSION=1.19.7 ARG GO_VERSION=1.19.7
ARG ALPINE_VERSION=3.16 ARG ALPINE_VERSION=3.16
ARG GOLANGCI_LINT_VERSION=v1.49.0 ARG GOLANGCI_LINT_VERSION=v1.52.2
FROM golangci/golangci-lint:${GOLANGCI_LINT_VERSION}-alpine AS golangci-lint FROM golangci/golangci-lint:${GOLANGCI_LINT_VERSION}-alpine AS golangci-lint

View File

@ -181,7 +181,7 @@ func (c *FakeCli) ManifestStore() manifeststore.Store {
} }
// RegistryClient returns a fake client for testing // RegistryClient returns a fake client for testing
func (c *FakeCli) RegistryClient(insecure bool) registryclient.RegistryClient { func (c *FakeCli) RegistryClient(bool) registryclient.RegistryClient {
return c.registryClient return c.registryClient
} }

View File

@ -4,30 +4,15 @@ import (
"context" "context"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/filters" "github.com/docker/docker/client"
"github.com/docker/docker/api/types/network"
) )
// FakeClient is a fake NetworkAPIClient // FakeClient is a fake NetworkAPIClient
type FakeClient struct { type FakeClient struct {
client.NetworkAPIClient
NetworkInspectFunc func(ctx context.Context, networkID string, options types.NetworkInspectOptions) (types.NetworkResource, error) NetworkInspectFunc func(ctx context.Context, networkID string, options types.NetworkInspectOptions) (types.NetworkResource, error)
} }
// NetworkConnect fakes connecting to a network
func (c *FakeClient) NetworkConnect(ctx context.Context, networkID, container string, config *network.EndpointSettings) error {
return nil
}
// NetworkCreate fakes creating a network
func (c *FakeClient) NetworkCreate(_ context.Context, _ string, options types.NetworkCreate) (types.NetworkCreateResponse, error) {
return types.NetworkCreateResponse{}, nil
}
// NetworkDisconnect fakes disconnecting from a network
func (c *FakeClient) NetworkDisconnect(ctx context.Context, networkID, container string, force bool) error {
return nil
}
// NetworkInspect fakes inspecting a network // NetworkInspect fakes inspecting a network
func (c *FakeClient) NetworkInspect(ctx context.Context, networkID string, options types.NetworkInspectOptions) (types.NetworkResource, error) { func (c *FakeClient) NetworkInspect(ctx context.Context, networkID string, options types.NetworkInspectOptions) (types.NetworkResource, error) {
if c.NetworkInspectFunc != nil { if c.NetworkInspectFunc != nil {
@ -35,23 +20,3 @@ func (c *FakeClient) NetworkInspect(ctx context.Context, networkID string, optio
} }
return types.NetworkResource{}, nil return types.NetworkResource{}, nil
} }
// NetworkInspectWithRaw fakes inspecting a network with a raw response
func (c *FakeClient) NetworkInspectWithRaw(_ context.Context, _ string, _ types.NetworkInspectOptions) (types.NetworkResource, []byte, error) {
return types.NetworkResource{}, nil, nil
}
// NetworkList fakes listing networks
func (c *FakeClient) NetworkList(_ context.Context, options types.NetworkListOptions) ([]types.NetworkResource, error) {
return nil, nil
}
// NetworkRemove fakes removing networks
func (c *FakeClient) NetworkRemove(ctx context.Context, networkID string) error {
return nil
}
// NetworksPrune fakes pruning networks
func (c *FakeClient) NetworksPrune(_ context.Context, pruneFilter filters.Args) (types.NetworksPruneReport, error) {
return types.NetworksPruneReport{}, nil
}

View File

@ -13,7 +13,7 @@ import (
) )
// GetOfflineNotaryRepository returns a OfflineNotaryRepository // GetOfflineNotaryRepository returns a OfflineNotaryRepository
func GetOfflineNotaryRepository(imgRefAndAuth trust.ImageRefAndAuth, actions []string) (client.Repository, error) { func GetOfflineNotaryRepository(trust.ImageRefAndAuth, []string) (client.Repository, error) {
return OfflineNotaryRepository{}, nil return OfflineNotaryRepository{}, nil
} }
@ -22,12 +22,12 @@ type OfflineNotaryRepository struct{}
// Initialize creates a new repository by using rootKey as the root Key for the // Initialize creates a new repository by using rootKey as the root Key for the
// TUF repository. // TUF repository.
func (o OfflineNotaryRepository) Initialize(rootKeyIDs []string, serverManagedRoles ...data.RoleName) error { func (o OfflineNotaryRepository) Initialize([]string, ...data.RoleName) error {
return storage.ErrOffline{} return storage.ErrOffline{}
} }
// InitializeWithCertificate initializes the repository with root keys and their corresponding certificates // InitializeWithCertificate initializes the repository with root keys and their corresponding certificates
func (o OfflineNotaryRepository) InitializeWithCertificate(rootKeyIDs []string, rootCerts []data.PublicKey, serverManagedRoles ...data.RoleName) error { func (o OfflineNotaryRepository) InitializeWithCertificate([]string, []data.PublicKey, ...data.RoleName) error {
return storage.ErrOffline{} return storage.ErrOffline{}
} }
@ -39,30 +39,30 @@ func (o OfflineNotaryRepository) Publish() error {
// AddTarget creates new changelist entries to add a target to the given roles // AddTarget creates new changelist entries to add a target to the given roles
// in the repository when the changelist gets applied at publish time. // in the repository when the changelist gets applied at publish time.
func (o OfflineNotaryRepository) AddTarget(target *client.Target, roles ...data.RoleName) error { func (o OfflineNotaryRepository) AddTarget(*client.Target, ...data.RoleName) error {
return nil return nil
} }
// RemoveTarget creates new changelist entries to remove a target from the given // RemoveTarget creates new changelist entries to remove a target from the given
// roles in the repository when the changelist gets applied at publish time. // roles in the repository when the changelist gets applied at publish time.
func (o OfflineNotaryRepository) RemoveTarget(targetName string, roles ...data.RoleName) error { func (o OfflineNotaryRepository) RemoveTarget(string, ...data.RoleName) error {
return nil return nil
} }
// ListTargets lists all targets for the current repository. The list of // ListTargets lists all targets for the current repository. The list of
// roles should be passed in order from highest to lowest priority. // roles should be passed in order from highest to lowest priority.
func (o OfflineNotaryRepository) ListTargets(roles ...data.RoleName) ([]*client.TargetWithRole, error) { func (o OfflineNotaryRepository) ListTargets(...data.RoleName) ([]*client.TargetWithRole, error) {
return nil, storage.ErrOffline{} return nil, storage.ErrOffline{}
} }
// GetTargetByName returns a target by the given name. // GetTargetByName returns a target by the given name.
func (o OfflineNotaryRepository) GetTargetByName(name string, roles ...data.RoleName) (*client.TargetWithRole, error) { func (o OfflineNotaryRepository) GetTargetByName(string, ...data.RoleName) (*client.TargetWithRole, error) {
return nil, storage.ErrOffline{} return nil, storage.ErrOffline{}
} }
// GetAllTargetMetadataByName searches the entire delegation role tree to find the specified target by name for all // GetAllTargetMetadataByName searches the entire delegation role tree to find the specified target by name for all
// roles, and returns a list of TargetSignedStructs for each time it finds the specified target. // roles, and returns a list of TargetSignedStructs for each time it finds the specified target.
func (o OfflineNotaryRepository) GetAllTargetMetadataByName(name string) ([]client.TargetSignedStruct, error) { func (o OfflineNotaryRepository) GetAllTargetMetadataByName(string) ([]client.TargetSignedStruct, error) {
return nil, storage.ErrOffline{} return nil, storage.ErrOffline{}
} }
@ -82,53 +82,53 @@ func (o OfflineNotaryRepository) GetDelegationRoles() ([]data.Role, error) {
} }
// AddDelegation creates changelist entries to add provided delegation public keys and paths. // AddDelegation creates changelist entries to add provided delegation public keys and paths.
func (o OfflineNotaryRepository) AddDelegation(name data.RoleName, delegationKeys []data.PublicKey, paths []string) error { func (o OfflineNotaryRepository) AddDelegation(data.RoleName, []data.PublicKey, []string) error {
return nil return nil
} }
// AddDelegationRoleAndKeys creates a changelist entry to add provided delegation public keys. // AddDelegationRoleAndKeys creates a changelist entry to add provided delegation public keys.
func (o OfflineNotaryRepository) AddDelegationRoleAndKeys(name data.RoleName, delegationKeys []data.PublicKey) error { func (o OfflineNotaryRepository) AddDelegationRoleAndKeys(data.RoleName, []data.PublicKey) error {
return nil return nil
} }
// AddDelegationPaths creates a changelist entry to add provided paths to an existing delegation. // AddDelegationPaths creates a changelist entry to add provided paths to an existing delegation.
func (o OfflineNotaryRepository) AddDelegationPaths(name data.RoleName, paths []string) error { func (o OfflineNotaryRepository) AddDelegationPaths(data.RoleName, []string) error {
return nil return nil
} }
// RemoveDelegationKeysAndPaths creates changelist entries to remove provided delegation key IDs and paths. // RemoveDelegationKeysAndPaths creates changelist entries to remove provided delegation key IDs and paths.
func (o OfflineNotaryRepository) RemoveDelegationKeysAndPaths(name data.RoleName, keyIDs, paths []string) error { func (o OfflineNotaryRepository) RemoveDelegationKeysAndPaths(data.RoleName, []string, []string) error {
return nil return nil
} }
// RemoveDelegationRole creates a changelist to remove all paths and keys from a role, and delete the role in its entirety. // RemoveDelegationRole creates a changelist to remove all paths and keys from a role, and delete the role in its entirety.
func (o OfflineNotaryRepository) RemoveDelegationRole(name data.RoleName) error { func (o OfflineNotaryRepository) RemoveDelegationRole(data.RoleName) error {
return nil return nil
} }
// RemoveDelegationPaths creates a changelist entry to remove provided paths from an existing delegation. // RemoveDelegationPaths creates a changelist entry to remove provided paths from an existing delegation.
func (o OfflineNotaryRepository) RemoveDelegationPaths(name data.RoleName, paths []string) error { func (o OfflineNotaryRepository) RemoveDelegationPaths(data.RoleName, []string) error {
return nil return nil
} }
// RemoveDelegationKeys creates a changelist entry to remove provided keys from an existing delegation. // RemoveDelegationKeys creates a changelist entry to remove provided keys from an existing delegation.
func (o OfflineNotaryRepository) RemoveDelegationKeys(name data.RoleName, keyIDs []string) error { func (o OfflineNotaryRepository) RemoveDelegationKeys(data.RoleName, []string) error {
return nil return nil
} }
// ClearDelegationPaths creates a changelist entry to remove all paths from an existing delegation. // ClearDelegationPaths creates a changelist entry to remove all paths from an existing delegation.
func (o OfflineNotaryRepository) ClearDelegationPaths(name data.RoleName) error { func (o OfflineNotaryRepository) ClearDelegationPaths(data.RoleName) error {
return nil return nil
} }
// Witness creates change objects to witness (i.e. re-sign) the given // Witness creates change objects to witness (i.e. re-sign) the given
// roles on the next publish. One change is created per role // roles on the next publish. One change is created per role
func (o OfflineNotaryRepository) Witness(roles ...data.RoleName) ([]data.RoleName, error) { func (o OfflineNotaryRepository) Witness(...data.RoleName) ([]data.RoleName, error) {
return nil, nil return nil, nil
} }
// RotateKey rotates a private key and returns the public component from the remote server // RotateKey rotates a private key and returns the public component from the remote server
func (o OfflineNotaryRepository) RotateKey(role data.RoleName, serverManagesKey bool, keyList []string) error { func (o OfflineNotaryRepository) RotateKey(data.RoleName, bool, []string) error {
return storage.ErrOffline{} return storage.ErrOffline{}
} }
@ -139,7 +139,7 @@ func (o OfflineNotaryRepository) GetCryptoService() signed.CryptoService {
// SetLegacyVersions allows the number of legacy versions of the root // SetLegacyVersions allows the number of legacy versions of the root
// to be inspected for old signing keys to be configured. // to be inspected for old signing keys to be configured.
func (o OfflineNotaryRepository) SetLegacyVersions(version int) {} func (o OfflineNotaryRepository) SetLegacyVersions(int) {}
// GetGUN is a getter for the GUN object from a Repository // GetGUN is a getter for the GUN object from a Repository
func (o OfflineNotaryRepository) GetGUN() data.GUN { func (o OfflineNotaryRepository) GetGUN() data.GUN {
@ -147,7 +147,7 @@ func (o OfflineNotaryRepository) GetGUN() data.GUN {
} }
// GetUninitializedNotaryRepository returns an UninitializedNotaryRepository // GetUninitializedNotaryRepository returns an UninitializedNotaryRepository
func GetUninitializedNotaryRepository(imgRefAndAuth trust.ImageRefAndAuth, actions []string) (client.Repository, error) { func GetUninitializedNotaryRepository(trust.ImageRefAndAuth, []string) (client.Repository, error) {
return UninitializedNotaryRepository{}, nil return UninitializedNotaryRepository{}, nil
} }
@ -160,12 +160,12 @@ type UninitializedNotaryRepository struct {
// Initialize creates a new repository by using rootKey as the root Key for the // Initialize creates a new repository by using rootKey as the root Key for the
// TUF repository. // TUF repository.
func (u UninitializedNotaryRepository) Initialize(rootKeyIDs []string, serverManagedRoles ...data.RoleName) error { func (u UninitializedNotaryRepository) Initialize([]string, ...data.RoleName) error {
return client.ErrRepositoryNotExist{} return client.ErrRepositoryNotExist{}
} }
// InitializeWithCertificate initializes the repository with root keys and their corresponding certificates // InitializeWithCertificate initializes the repository with root keys and their corresponding certificates
func (u UninitializedNotaryRepository) InitializeWithCertificate(rootKeyIDs []string, rootCerts []data.PublicKey, serverManagedRoles ...data.RoleName) error { func (u UninitializedNotaryRepository) InitializeWithCertificate([]string, []data.PublicKey, ...data.RoleName) error {
return client.ErrRepositoryNotExist{} return client.ErrRepositoryNotExist{}
} }
@ -177,18 +177,18 @@ func (u UninitializedNotaryRepository) Publish() error {
// ListTargets lists all targets for the current repository. The list of // ListTargets lists all targets for the current repository. The list of
// roles should be passed in order from highest to lowest priority. // roles should be passed in order from highest to lowest priority.
func (u UninitializedNotaryRepository) ListTargets(roles ...data.RoleName) ([]*client.TargetWithRole, error) { func (u UninitializedNotaryRepository) ListTargets(...data.RoleName) ([]*client.TargetWithRole, error) {
return nil, client.ErrRepositoryNotExist{} return nil, client.ErrRepositoryNotExist{}
} }
// GetTargetByName returns a target by the given name. // GetTargetByName returns a target by the given name.
func (u UninitializedNotaryRepository) GetTargetByName(name string, roles ...data.RoleName) (*client.TargetWithRole, error) { func (u UninitializedNotaryRepository) GetTargetByName(string, ...data.RoleName) (*client.TargetWithRole, error) {
return nil, client.ErrRepositoryNotExist{} return nil, client.ErrRepositoryNotExist{}
} }
// GetAllTargetMetadataByName searches the entire delegation role tree to find the specified target by name for all // GetAllTargetMetadataByName searches the entire delegation role tree to find the specified target by name for all
// roles, and returns a list of TargetSignedStructs for each time it finds the specified target. // roles, and returns a list of TargetSignedStructs for each time it finds the specified target.
func (u UninitializedNotaryRepository) GetAllTargetMetadataByName(name string) ([]client.TargetSignedStruct, error) { func (u UninitializedNotaryRepository) GetAllTargetMetadataByName(string) ([]client.TargetSignedStruct, error) {
return nil, client.ErrRepositoryNotExist{} return nil, client.ErrRepositoryNotExist{}
} }
@ -203,12 +203,12 @@ func (u UninitializedNotaryRepository) GetDelegationRoles() ([]data.Role, error)
} }
// RotateKey rotates a private key and returns the public component from the remote server // RotateKey rotates a private key and returns the public component from the remote server
func (u UninitializedNotaryRepository) RotateKey(role data.RoleName, serverManagesKey bool, keyList []string) error { func (u UninitializedNotaryRepository) RotateKey(data.RoleName, bool, []string) error {
return client.ErrRepositoryNotExist{} return client.ErrRepositoryNotExist{}
} }
// GetEmptyTargetsNotaryRepository returns an EmptyTargetsNotaryRepository // GetEmptyTargetsNotaryRepository returns an EmptyTargetsNotaryRepository
func GetEmptyTargetsNotaryRepository(imgRefAndAuth trust.ImageRefAndAuth, actions []string) (client.Repository, error) { func GetEmptyTargetsNotaryRepository(trust.ImageRefAndAuth, []string) (client.Repository, error) {
return EmptyTargetsNotaryRepository{}, nil return EmptyTargetsNotaryRepository{}, nil
} }
@ -220,12 +220,12 @@ type EmptyTargetsNotaryRepository struct {
// Initialize creates a new repository by using rootKey as the root Key for the // Initialize creates a new repository by using rootKey as the root Key for the
// TUF repository. // TUF repository.
func (e EmptyTargetsNotaryRepository) Initialize(rootKeyIDs []string, serverManagedRoles ...data.RoleName) error { func (e EmptyTargetsNotaryRepository) Initialize([]string, ...data.RoleName) error {
return nil return nil
} }
// InitializeWithCertificate initializes the repository with root keys and their corresponding certificates // InitializeWithCertificate initializes the repository with root keys and their corresponding certificates
func (e EmptyTargetsNotaryRepository) InitializeWithCertificate(rootKeyIDs []string, rootCerts []data.PublicKey, serverManagedRoles ...data.RoleName) error { func (e EmptyTargetsNotaryRepository) InitializeWithCertificate([]string, []data.PublicKey, ...data.RoleName) error {
return nil return nil
} }
@ -237,12 +237,12 @@ func (e EmptyTargetsNotaryRepository) Publish() error {
// ListTargets lists all targets for the current repository. The list of // ListTargets lists all targets for the current repository. The list of
// roles should be passed in order from highest to lowest priority. // roles should be passed in order from highest to lowest priority.
func (e EmptyTargetsNotaryRepository) ListTargets(roles ...data.RoleName) ([]*client.TargetWithRole, error) { func (e EmptyTargetsNotaryRepository) ListTargets(...data.RoleName) ([]*client.TargetWithRole, error) {
return []*client.TargetWithRole{}, nil return []*client.TargetWithRole{}, nil
} }
// GetTargetByName returns a target by the given name. // GetTargetByName returns a target by the given name.
func (e EmptyTargetsNotaryRepository) GetTargetByName(name string, roles ...data.RoleName) (*client.TargetWithRole, error) { func (e EmptyTargetsNotaryRepository) GetTargetByName(name string, _ ...data.RoleName) (*client.TargetWithRole, error) {
return nil, client.ErrNoSuchTarget(name) return nil, client.ErrNoSuchTarget(name)
} }
@ -281,12 +281,12 @@ func (e EmptyTargetsNotaryRepository) GetDelegationRoles() ([]data.Role, error)
} }
// RotateKey rotates a private key and returns the public component from the remote server // RotateKey rotates a private key and returns the public component from the remote server
func (e EmptyTargetsNotaryRepository) RotateKey(role data.RoleName, serverManagesKey bool, keyList []string) error { func (e EmptyTargetsNotaryRepository) RotateKey(data.RoleName, bool, []string) error {
return nil return nil
} }
// GetLoadedNotaryRepository returns a LoadedNotaryRepository // GetLoadedNotaryRepository returns a LoadedNotaryRepository
func GetLoadedNotaryRepository(imgRefAndAuth trust.ImageRefAndAuth, actions []string) (client.Repository, error) { func GetLoadedNotaryRepository(trust.ImageRefAndAuth, []string) (client.Repository, error) {
return LoadedNotaryRepository{}, nil return LoadedNotaryRepository{}, nil
} }
@ -506,7 +506,7 @@ func (l LoadedNotaryRepository) GetCryptoService() signed.CryptoService {
} }
// GetLoadedWithNoSignersNotaryRepository returns a LoadedWithNoSignersNotaryRepository // GetLoadedWithNoSignersNotaryRepository returns a LoadedWithNoSignersNotaryRepository
func GetLoadedWithNoSignersNotaryRepository(imgRefAndAuth trust.ImageRefAndAuth, actions []string) (client.Repository, error) { func GetLoadedWithNoSignersNotaryRepository(trust.ImageRefAndAuth, []string) (client.Repository, error) {
return LoadedWithNoSignersNotaryRepository{}, nil return LoadedWithNoSignersNotaryRepository{}, nil
} }
@ -529,7 +529,7 @@ func (l LoadedWithNoSignersNotaryRepository) ListTargets(roles ...data.RoleName)
} }
// GetTargetByName returns a target by the given name. // GetTargetByName returns a target by the given name.
func (l LoadedWithNoSignersNotaryRepository) GetTargetByName(name string, roles ...data.RoleName) (*client.TargetWithRole, error) { func (l LoadedWithNoSignersNotaryRepository) GetTargetByName(name string, _ ...data.RoleName) (*client.TargetWithRole, error) {
if name == "" || name == loadedGreenTarget.Name { if name == "" || name == loadedGreenTarget.Name {
return &client.TargetWithRole{Target: loadedGreenTarget, Role: data.CanonicalTargetsRole}, nil return &client.TargetWithRole{Target: loadedGreenTarget, Role: data.CanonicalTargetsRole}, nil
} }

View File

@ -21,15 +21,15 @@ const (
// This function only handles rudimentary formatting; no validation is performed, // This function only handles rudimentary formatting; no validation is performed,
// as the list of available capabilities can be updated over time, thus should be // as the list of available capabilities can be updated over time, thus should be
// handled by the daemon. // handled by the daemon.
func NormalizeCapability(cap string) string { func NormalizeCapability(capability string) string {
cap = strings.ToUpper(strings.TrimSpace(cap)) capability = strings.ToUpper(strings.TrimSpace(capability))
if cap == AllCapabilities || cap == ResetCapabilities { if capability == AllCapabilities || capability == ResetCapabilities {
return cap return capability
} }
if !strings.HasPrefix(cap, "CAP_") { if !strings.HasPrefix(capability, "CAP_") {
cap = "CAP_" + cap capability = "CAP_" + capability
} }
return cap return capability
} }
// CapabilitiesMap normalizes the given capabilities and converts them to a map. // CapabilitiesMap normalizes the given capabilities and converts them to a map.