Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
be97731
cli/command/container: fix redefinition of the built-in function clos…
thaJeztah Mar 29, 2023
78c4745
cli/command/context: remove redundant if ...; err != nil check (revive)
thaJeztah Mar 29, 2023
f08252c
cli/command/stack: deprecate now obsolete wrappers
thaJeztah Mar 29, 2023
b4aff3a
cli/command/completion: NoComplete(): remove unused argument (revive)
thaJeztah Mar 29, 2023
c3d7f16
cli/command: RunPrune(): remove name for unused "all" parameter (revive)
thaJeztah Mar 29, 2023
92506af
cli/command/service/progress: remove name for unused parameter (revive)
thaJeztah Mar 29, 2023
9252fae
cli/registry/client: AuthorizeRequest(): remove name for unused arg (…
thaJeztah Mar 29, 2023
f5fad18
opts: NormalizeCapability(): fix redefinition of the built-in functio…
thaJeztah Mar 29, 2023
a2d5328
cli/trust: remove name for unused args (revive)
thaJeztah Mar 29, 2023
ac024a4
internal/test/network: FakeClient: embed interface to remove boilerpl…
thaJeztah Mar 30, 2023
66c66bd
cli/command/config: fakeClient: include context in fake client (revive)
thaJeztah Mar 30, 2023
9dd012a
cli/command/secret: fakeClient: include context in fake client (revive)
thaJeztah Mar 30, 2023
5563c5a
cli/command/checkpoint: fakeClient: remove name for unused arg (revive)
thaJeztah Mar 30, 2023
45b5676
cli/command/container: fakeClient: remove name for unused arg (revive)
thaJeztah Mar 30, 2023
38ef40e
cli/command/idresolver: fakeClient: remove name for unused arg (revive)
thaJeztah Mar 30, 2023
ae5a86b
cli/command/image/build: remove name for unused arg (revive)
thaJeztah Mar 30, 2023
316c499
cli/command/image: fakeClient: remove name for unused arg (revive)
thaJeztah Mar 30, 2023
92d9e3b
cli/command/network: fakeClient: remove name for unused arg (revive)
thaJeztah Mar 30, 2023
625988c
cli/command/node: fakeClient: remove name for unused arg (revive)
thaJeztah Mar 30, 2023
da3416c
cli/command/plugin: fakeClient: remove name for unused arg (revive)
thaJeztah Mar 30, 2023
5254081
cli/command/registry: fakeClient: remove name for unused arg (revive)
thaJeztah Mar 30, 2023
c69640d
cli/command/service: fakeClient: remove name for unused arg (revive)
thaJeztah Mar 30, 2023
b0d0b0e
cli/command/stack: fakeClient: remove name for unused arg (revive)
thaJeztah Mar 30, 2023
40a51d5
cli/command/swarm: fakeClient: remove name for unused arg (revive)
thaJeztah Mar 30, 2023
b32b280
cli/command/task: fakeClient: remove name for unused arg (revive)
thaJeztah Mar 30, 2023
546cf6d
cli/command/trust: fakeClient: remove name for unused arg (revive)
thaJeztah Mar 30, 2023
607f290
cli/command/volume: remove name for unused arg (revive)
thaJeztah Mar 30, 2023
6355bce
cli/compose/convert: fakeClient: remove name for unused arg (revive)
thaJeztah Mar 30, 2023
7c8680c
cli/compose/schema: remove name for unused arg (revive)
thaJeztah Mar 30, 2023
dd6ede2
cli/config/configfile: mockNativeStore: remove name for unused arg (r…
thaJeztah Mar 30, 2023
90380d9
cli/connhelper/commandconn: remove name for unused arg (revive)
thaJeztah Mar 30, 2023
20a70cb
internal/test/notary: remove name for unused arg (revive)
thaJeztah Mar 30, 2023
399ded9
internal/test: FakeCli: remove name for unused arg (revive)
thaJeztah Mar 30, 2023
b8747b0
update golangci-lint to v1.52.2
thaJeztah Mar 28, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions cli/command/checkpoint/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,21 @@ type fakeClient struct {
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 {
return cli.checkpointCreateFunc(container, options)
}
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 {
return cli.checkpointDeleteFunc(container, options)
}
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 {
return cli.checkpointListFunc(container, options)
}
Expand Down
2 changes: 1 addition & 1 deletion cli/command/completion/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,6 @@ func NetworkNames(dockerCli command.Cli) ValidArgsFn {
}

// 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
}
14 changes: 7 additions & 7 deletions cli/command/config/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,34 +10,34 @@ import (

type fakeClient struct {
client.Client
configCreateFunc func(swarm.ConfigSpec) (types.ConfigCreateResponse, error)
configInspectFunc func(string) (swarm.Config, []byte, error)
configListFunc func(types.ConfigListOptions) ([]swarm.Config, error)
configCreateFunc func(context.Context, swarm.ConfigSpec) (types.ConfigCreateResponse, error)
configInspectFunc func(context.Context, string) (swarm.Config, []byte, error)
configListFunc func(context.Context, types.ConfigListOptions) ([]swarm.Config, error)
configRemoveFunc func(string) error
}

func (c *fakeClient) ConfigCreate(ctx context.Context, spec swarm.ConfigSpec) (types.ConfigCreateResponse, error) {
if c.configCreateFunc != nil {
return c.configCreateFunc(spec)
return c.configCreateFunc(ctx, spec)
}
return types.ConfigCreateResponse{}, nil
}

func (c *fakeClient) ConfigInspectWithRaw(ctx context.Context, id string) (swarm.Config, []byte, error) {
if c.configInspectFunc != nil {
return c.configInspectFunc(id)
return c.configInspectFunc(ctx, id)
}
return swarm.Config{}, nil, nil
}

func (c *fakeClient) ConfigList(ctx context.Context, options types.ConfigListOptions) ([]swarm.Config, error) {
if c.configListFunc != nil {
return c.configListFunc(options)
return c.configListFunc(ctx, options)
}
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 {
return c.configRemoveFunc(name)
}
Expand Down
11 changes: 6 additions & 5 deletions cli/command/config/create_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package config

import (
"context"
"io"
"os"
"path/filepath"
Expand All @@ -22,7 +23,7 @@ const configDataFile = "config-create-with-name.golden"
func TestConfigCreateErrors(t *testing.T) {
testCases := []struct {
args []string
configCreateFunc func(swarm.ConfigSpec) (types.ConfigCreateResponse, error)
configCreateFunc func(context.Context, swarm.ConfigSpec) (types.ConfigCreateResponse, error)
expectedError string
}{
{
Expand All @@ -35,7 +36,7 @@ func TestConfigCreateErrors(t *testing.T) {
},
{
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")
},
expectedError: "error creating config",
Expand All @@ -57,7 +58,7 @@ func TestConfigCreateWithName(t *testing.T) {
name := "foo"
var actual []byte
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 {
return types.ConfigCreateResponse{}, errors.Errorf("expected name %q, got %q", name, spec.Name)
}
Expand Down Expand Up @@ -96,7 +97,7 @@ func TestConfigCreateWithLabels(t *testing.T) {
}

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) {
return types.ConfigCreateResponse{}, errors.Errorf("expected %+v, got %+v", expected, spec)
}
Expand All @@ -122,7 +123,7 @@ func TestConfigCreateWithTemplatingDriver(t *testing.T) {
name := "foo"

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 {
return types.ConfigCreateResponse{}, errors.Errorf("expected name %q, got %q", name, spec.Name)
}
Expand Down
21 changes: 11 additions & 10 deletions cli/command/config/inspect_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package config

import (
"context"
"fmt"
"io"
"testing"
Expand All @@ -18,15 +19,15 @@ func TestConfigInspectErrors(t *testing.T) {
testCases := []struct {
args []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: "requires at least 1 argument",
},
{
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")
},
expectedError: "error while inspecting the config",
Expand All @@ -40,7 +41,7 @@ func TestConfigInspectErrors(t *testing.T) {
},
{
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" {
return *Config(ConfigName("foo")), nil, nil
}
Expand Down Expand Up @@ -68,12 +69,12 @@ func TestConfigInspectWithoutFormat(t *testing.T) {
testCases := []struct {
name string
args []string
configInspectFunc func(configID string) (swarm.Config, []byte, error)
configInspectFunc func(_ context.Context, configID string) (swarm.Config, []byte, error)
}{
{
name: "single-config",
args: []string{"foo"},
configInspectFunc: func(name string) (swarm.Config, []byte, error) {
configInspectFunc: func(_ context.Context, name string) (swarm.Config, []byte, error) {
if name != "foo" {
return swarm.Config{}, nil, errors.Errorf("Invalid name, expected %s, got %s", "foo", name)
}
Expand All @@ -83,7 +84,7 @@ func TestConfigInspectWithoutFormat(t *testing.T) {
{
name: "multiple-configs-with-labels",
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{
"label1": "label-foo",
})), nil, nil
Expand All @@ -100,7 +101,7 @@ func TestConfigInspectWithoutFormat(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{
"label1": "label-foo",
})), nil, nil
Expand All @@ -109,7 +110,7 @@ func TestConfigInspectWithFormat(t *testing.T) {
name string
format string
args []string
configInspectFunc func(name string) (swarm.Config, []byte, error)
configInspectFunc func(_ context.Context, name string) (swarm.Config, []byte, error)
}{
{
name: "simple-template",
Expand Down Expand Up @@ -139,11 +140,11 @@ func TestConfigInspectWithFormat(t *testing.T) {
func TestConfigInspectPretty(t *testing.T) {
testCases := []struct {
name string
configInspectFunc func(string) (swarm.Config, []byte, error)
configInspectFunc func(context.Context, string) (swarm.Config, []byte, error)
}{
{
name: "simple",
configInspectFunc: func(id string) (swarm.Config, []byte, error) {
configInspectFunc: func(_ context.Context, id string) (swarm.Config, []byte, error) {
return *Config(
ConfigLabels(map[string]string{
"lbl1": "value1",
Expand Down
15 changes: 8 additions & 7 deletions cli/command/config/ls_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package config

import (
"context"
"io"
"testing"
"time"
Expand All @@ -19,15 +20,15 @@ import (
func TestConfigListErrors(t *testing.T) {
testCases := []struct {
args []string
configListFunc func(types.ConfigListOptions) ([]swarm.Config, error)
configListFunc func(context.Context, types.ConfigListOptions) ([]swarm.Config, error)
expectedError string
}{
{
args: []string{"foo"},
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")
},
expectedError: "error listing configs",
Expand All @@ -47,7 +48,7 @@ func TestConfigListErrors(t *testing.T) {

func TestConfigList(t *testing.T) {
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{
*Config(ConfigID("ID-1-foo"),
ConfigName("1-foo"),
Expand Down Expand Up @@ -77,7 +78,7 @@ func TestConfigList(t *testing.T) {

func TestConfigListWithQuietOption(t *testing.T) {
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{
*Config(ConfigID("ID-foo"), ConfigName("foo")),
*Config(ConfigID("ID-bar"), ConfigName("bar"), ConfigLabels(map[string]string{
Expand All @@ -94,7 +95,7 @@ func TestConfigListWithQuietOption(t *testing.T) {

func TestConfigListWithConfigFormat(t *testing.T) {
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{
*Config(ConfigID("ID-foo"), ConfigName("foo")),
*Config(ConfigID("ID-bar"), ConfigName("bar"), ConfigLabels(map[string]string{
Expand All @@ -113,7 +114,7 @@ func TestConfigListWithConfigFormat(t *testing.T) {

func TestConfigListWithFormat(t *testing.T) {
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{
*Config(ConfigID("ID-foo"), ConfigName("foo")),
*Config(ConfigID("ID-bar"), ConfigName("bar"), ConfigLabels(map[string]string{
Expand All @@ -130,7 +131,7 @@ func TestConfigListWithFormat(t *testing.T) {

func TestConfigListWithFilter(t *testing.T) {
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("lbl1=Label-bar", options.Filters.Get("label")[0]))
return []swarm.Config{
Expand Down
4 changes: 2 additions & 2 deletions cli/command/container/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func (f *fakeClient) ContainerExecInspect(_ context.Context, execID string) (typ
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
}

Expand All @@ -89,7 +89,7 @@ func (f *fakeClient) ContainerRemove(ctx context.Context, container string, opti
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 {
return f.imageCreateFunc(parentReference, options)
}
Expand Down
2 changes: 1 addition & 1 deletion cli/command/container/prune.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,6 @@ func runPrune(dockerCli command.Cli, options pruneOptions) (spaceReclaimed uint6

// RunPrune calls the Container Prune API
// 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})
}
4 changes: 2 additions & 2 deletions cli/command/container/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,11 @@ func runContainer(dockerCli command.Cli, opts *runOptions, copts *containerOptio
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 {
return err
}
defer close()
defer closeFn()
}

statusChan := waitExitOrRemoved(ctx, dockerCli, createResponse.ID, copts.autoRemove)
Expand Down
5 changes: 1 addition & 4 deletions cli/command/context/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,7 @@ func createNewContext(o *CreateOptions, cli command.Cli, s store.Writer) error {
if err := s.CreateOrUpdate(contextMetadata); err != nil {
return err
}
if err := s.ResetTLSMaterial(o.Name, &contextTLSData); err != nil {
return err
}
return nil
return s.ResetTLSMaterial(o.Name, &contextTLSData)
}

func checkContextNameForCreation(s store.Reader, name string) error {
Expand Down
4 changes: 2 additions & 2 deletions cli/command/idresolver/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ type fakeClient struct {
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 {
return cli.nodeInspectFunc(nodeID)
}
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 {
return cli.serviceInspectFunc(serviceID)
}
Expand Down
2 changes: 1 addition & 1 deletion cli/command/image/build/context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (

const dockerfileContents = "FROM busybox"

func prepareEmpty(t *testing.T) string {
func prepareEmpty(_ *testing.T) string {
return ""
}

Expand Down
2 changes: 1 addition & 1 deletion cli/command/image/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func (cli *fakeClient) ImageLoad(_ context.Context, input io.Reader, quiet bool)
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 {
return cli.imageListFunc(options)
}
Expand Down
2 changes: 1 addition & 1 deletion cli/command/network/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@ func (c *fakeClient) NetworkRemove(ctx context.Context, networkID string) error
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
}
2 changes: 1 addition & 1 deletion cli/command/network/prune.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func runPrune(dockerCli command.Cli, options pruneOptions) (output string, err e

// RunPrune calls the Network Prune API
// 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})
return 0, output, err
}
Loading