From c092f42b29e35c4b8b0e75fa87e449767a11ea56 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 29 Mar 2023 15:32:00 +0200 Subject: [PATCH 01/34] cli/command/container: fix redefinition of the built-in function close (revive) cli/command/container/run.go:176:3: redefines-builtin-id: redefinition of the built-in function close (revive) close, err := attachContainer(ctx, dockerCli, &errCh, config, createResponse.ID) ^ Signed-off-by: Sebastiaan van Stijn (cherry picked from commit be97731f1a64eec991d9d75987205126da5be04a) Signed-off-by: Sebastiaan van Stijn --- cli/command/container/run.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cli/command/container/run.go b/cli/command/container/run.go index f538c04a1d..fd4dccae0b 100644 --- a/cli/command/container/run.go +++ b/cli/command/container/run.go @@ -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) From 9cc20a29ce3ebf6cac7b059785055697635cca6f Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 29 Mar 2023 15:33:35 +0200 Subject: [PATCH 02/34] cli/command/context: remove redundant if ...; err != nil check (revive) cli/command/context/create.go:121:2: if-return: redundant if ...; err != nil check, just return error instead. (revive) if err := s.ResetTLSMaterial(o.Name, &contextTLSData); err != nil { return err } Signed-off-by: Sebastiaan van Stijn (cherry picked from commit 78c474539bf3573ad044747dee2277953c296aba) Signed-off-by: Sebastiaan van Stijn --- cli/command/context/create.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/cli/command/context/create.go b/cli/command/context/create.go index d912dff375..757d40adef 100644 --- a/cli/command/context/create.go +++ b/cli/command/context/create.go @@ -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 { From de94fd5ecf6ee7430f9a9ec4f0bf90cf06befde1 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 29 Mar 2023 15:42:17 +0200 Subject: [PATCH 03/34] cli/command/stack: deprecate now obsolete wrappers These wrappers were added to abstract stack deploy to k8s and swarm. Now that support for deploying to k8s was removed, we can remove these wrappers. This deprecates: - RunDeploy() - RunPs() - RunRemove() - GetServices() This also addresses some linting failers, due to these functions having unused arguments: cli/command/stack/deploy.go:51:39: unused-parameter: parameter 'flags' seems to be unused, consider removing or renaming it as _ (revive) func RunDeploy(dockerCli command.Cli, flags *pflag.FlagSet, config *composetypes.Config, opts options.Deploy) error { ^ cli/command/stack/ps.go:42:35: unused-parameter: parameter 'flags' seems to be unused, consider removing or renaming it as _ (revive) func RunPs(dockerCli command.Cli, flags *pflag.FlagSet, opts options.PS) error { ^ cli/command/stack/remove.go:35:39: unused-parameter: parameter 'flags' seems to be unused, consider removing or renaming it as _ (revive) func RunRemove(dockerCli command.Cli, flags *pflag.FlagSet, opts options.Remove) error { ^ cli/command/stack/list.go:37:14: unused-parameter: parameter 'cmd' seems to be unused, consider removing or renaming it as _ (revive) func RunList(cmd *cobra.Command, dockerCli command.Cli, opts options.List) error { ^ cli/command/stack/services.go:56:41: unused-parameter: parameter 'flags' seems to be unused, consider removing or renaming it as _ (revive) func GetServices(dockerCli command.Cli, flags *pflag.FlagSet, opts options.Services) ([]swarmtypes.Service, error) { ^ Signed-off-by: Sebastiaan van Stijn (cherry picked from commit f08252c10a16beac0ad40348118a96fa6b447f19) Signed-off-by: Sebastiaan van Stijn --- cli/command/stack/deploy.go | 8 +++++--- cli/command/stack/list.go | 14 +++++++------- cli/command/stack/ps.go | 8 +++++--- cli/command/stack/remove.go | 8 +++++--- cli/command/stack/services.go | 12 +++++++----- 5 files changed, 29 insertions(+), 21 deletions(-) diff --git a/cli/command/stack/deploy.go b/cli/command/stack/deploy.go index 1c9643e3ef..8b977ad0a1 100644 --- a/cli/command/stack/deploy.go +++ b/cli/command/stack/deploy.go @@ -28,7 +28,7 @@ func newDeployCommand(dockerCli command.Cli) *cobra.Command { if err != nil { 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) { return completeNames(dockerCli)(cmd, args, toComplete) @@ -47,7 +47,9 @@ func newDeployCommand(dockerCli command.Cli) *cobra.Command { return cmd } -// 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 { +// RunDeploy performs a stack deploy against the specified swarm cluster. +// +// 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) } diff --git a/cli/command/stack/list.go b/cli/command/stack/list.go index 40c1898cc6..fc5b03d651 100644 --- a/cli/command/stack/list.go +++ b/cli/command/stack/list.go @@ -23,7 +23,7 @@ func newListCommand(dockerCli command.Cli) *cobra.Command { Short: "List stacks", Args: cli.NoArgs, RunE: func(cmd *cobra.Command, args []string) error { - return RunList(cmd, dockerCli, opts) + return RunList(dockerCli, opts) }, ValidArgsFunction: completion.NoComplete, } @@ -34,24 +34,24 @@ func newListCommand(dockerCli command.Cli) *cobra.Command { } // RunList performs a stack list against the specified swarm cluster -func RunList(cmd *cobra.Command, dockerCli command.Cli, opts options.List) error { - stacks := []*formatter.Stack{} +func RunList(dockerCli command.Cli, opts options.List) error { ss, err := swarm.GetStacks(dockerCli) if err != nil { return err } + stacks := make([]*formatter.Stack, 0, len(ss)) stacks = append(stacks, ss...) return format(dockerCli, opts, stacks) } func format(dockerCli command.Cli, opts options.List, stacks []*formatter.Stack) error { - format := formatter.Format(opts.Format) - if format == "" || format == formatter.TableFormatKey { - format = formatter.SwarmStackTableFormat + fmt := formatter.Format(opts.Format) + if fmt == "" || fmt == formatter.TableFormatKey { + fmt = formatter.SwarmStackTableFormat } stackCtx := formatter.Context{ Output: dockerCli.Out(), - Format: format, + Format: fmt, } sort.Slice(stacks, func(i, j int) bool { return sortorder.NaturalLess(stacks[i].Name, stacks[j].Name) || diff --git a/cli/command/stack/ps.go b/cli/command/stack/ps.go index 84c250ea91..f962b895a7 100644 --- a/cli/command/stack/ps.go +++ b/cli/command/stack/ps.go @@ -23,7 +23,7 @@ func newPsCommand(dockerCli command.Cli) *cobra.Command { if err := validateStackName(opts.Namespace); err != nil { 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) { return completeNames(dockerCli)(cmd, args, toComplete) @@ -38,7 +38,9 @@ func newPsCommand(dockerCli command.Cli) *cobra.Command { return cmd } -// RunPs performs a stack ps against the specified swarm cluster -func RunPs(dockerCli command.Cli, flags *pflag.FlagSet, opts options.PS) error { +// RunPs performs a stack ps against the specified swarm cluster. +// +// Deprecated: use [swarm.RunPS] instead. +func RunPs(dockerCli command.Cli, _ *pflag.FlagSet, opts options.PS) error { return swarm.RunPS(dockerCli, opts) } diff --git a/cli/command/stack/remove.go b/cli/command/stack/remove.go index 9e55e65a7e..34827666d0 100644 --- a/cli/command/stack/remove.go +++ b/cli/command/stack/remove.go @@ -22,7 +22,7 @@ func newRemoveCommand(dockerCli command.Cli) *cobra.Command { if err := validateStackNames(opts.Namespaces); err != nil { 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) { return completeNames(dockerCli)(cmd, args, toComplete) @@ -31,7 +31,9 @@ func newRemoveCommand(dockerCli command.Cli) *cobra.Command { return cmd } -// RunRemove performs a stack remove against the specified swarm cluster -func RunRemove(dockerCli command.Cli, flags *pflag.FlagSet, opts options.Remove) error { +// RunRemove performs a stack remove against the specified swarm cluster. +// +// Deprecated: use [swarm.RunRemove] instead. +func RunRemove(dockerCli command.Cli, _ *pflag.FlagSet, opts options.Remove) error { return swarm.RunRemove(dockerCli, opts) } diff --git a/cli/command/stack/services.go b/cli/command/stack/services.go index cc0bdc5e2b..ef1947614a 100644 --- a/cli/command/stack/services.go +++ b/cli/command/stack/services.go @@ -30,7 +30,7 @@ func newServicesCommand(dockerCli command.Cli) *cobra.Command { if err := validateStackName(opts.Namespace); err != nil { return err } - return RunServices(dockerCli, cmd.Flags(), opts) + return RunServices(dockerCli, opts) }, ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { 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 -func RunServices(dockerCli command.Cli, flags *pflag.FlagSet, opts options.Services) error { - services, err := GetServices(dockerCli, flags, opts) +func RunServices(dockerCli command.Cli, opts options.Services) error { + services, err := swarm.GetServices(dockerCli, opts) if err != nil { return err } return formatWrite(dockerCli, services, opts) } -// GetServices returns the services for the specified swarm cluster -func GetServices(dockerCli command.Cli, flags *pflag.FlagSet, opts options.Services) ([]swarmtypes.Service, error) { +// GetServices returns the services for the specified swarm cluster. +// +// Deprecated: use [swarm.GetServices] instead. +func GetServices(dockerCli command.Cli, _ *pflag.FlagSet, opts options.Services) ([]swarmtypes.Service, error) { return swarm.GetServices(dockerCli, opts) } From 10483a1bfef37ff6684d54ca03d6b18bf1ac73de Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 29 Mar 2023 15:43:51 +0200 Subject: [PATCH 04/34] cli/command/completion: NoComplete(): remove unused argument (revive) cli/command/completion/functions.go:97:17: unused-parameter: parameter 'cmd' seems to be unused, consider removing or renaming it as _ (revive) func NoComplete(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { ^ Signed-off-by: Sebastiaan van Stijn (cherry picked from commit b4aff3a14d004b12190be1ab3b584ced048ce607) Signed-off-by: Sebastiaan van Stijn --- cli/command/completion/functions.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/command/completion/functions.go b/cli/command/completion/functions.go index 484ab44812..f53ee84681 100644 --- a/cli/command/completion/functions.go +++ b/cli/command/completion/functions.go @@ -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 } From 3882e674e4750b8c9dd0246170a50dffa62a336b Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 29 Mar 2023 15:54:33 +0200 Subject: [PATCH 05/34] cli/command: RunPrune(): remove name for unused "all" parameter (revive) These functions must have the same signature, but only some of them accept an "all" boolean argument; https://github.com/docker/cli/blob/88924b180210be1b6b82a7ad1ac6732606ff270f/cli/command/system/prune.go#L79 cli/command/container/prune.go:78:38: unused-parameter: parameter 'all' seems to be unused, consider removing or renaming it as _ (revive) func RunPrune(dockerCli command.Cli, all bool, filter opts.FilterOpt) (uint64, string, error) { ^ cli/command/network/prune.go:73:38: unused-parameter: parameter 'all' seems to be unused, consider removing or renaming it as _ (revive) func RunPrune(dockerCli command.Cli, all bool, filter opts.FilterOpt) (uint64, string, error) { ^ cli/command/volume/prune.go:78:38: unused-parameter: parameter 'all' seems to be unused, consider removing or renaming it as _ (revive) func RunPrune(dockerCli command.Cli, all bool, filter opts.FilterOpt) (uint64, string, error) { ^ Signed-off-by: Sebastiaan van Stijn (cherry picked from commit c3d7f167bd2586fa597471c206a2d32deeea85e5) Signed-off-by: Sebastiaan van Stijn --- cli/command/container/prune.go | 2 +- cli/command/network/prune.go | 2 +- cli/command/volume/prune.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cli/command/container/prune.go b/cli/command/container/prune.go index 225ab5f2d2..868560ef71 100644 --- a/cli/command/container/prune.go +++ b/cli/command/container/prune.go @@ -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}) } diff --git a/cli/command/network/prune.go b/cli/command/network/prune.go index 928edb3344..460a5b5646 100644 --- a/cli/command/network/prune.go +++ b/cli/command/network/prune.go @@ -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 } diff --git a/cli/command/volume/prune.go b/cli/command/volume/prune.go index e126f133b1..a85cb38833 100644 --- a/cli/command/volume/prune.go +++ b/cli/command/volume/prune.go @@ -98,6 +98,6 @@ func runPrune(dockerCli command.Cli, options pruneOptions) (spaceReclaimed uint6 // RunPrune calls the Volume 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}) } From 9e8d522f77f7883047cf393b766484cc01fa0b63 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 29 Mar 2023 15:57:25 +0200 Subject: [PATCH 06/34] cli/command/service/progress: remove name for unused parameter (revive) This function must match the interface, but doesn't use the firs argument. cli/command/service/progress/progress.go:417:40: unused-parameter: parameter 'service' seems to be unused, consider removing or renaming it as _ (revive) func (u *globalProgressUpdater) update(service swarm.Service, tasks []swarm.Task, activeNodes map[string]struct{}, rollback bool) (bool, error) { ^ Signed-off-by: Sebastiaan van Stijn (cherry picked from commit 92506afd4931e4543f32a54a1b7be0474060f71c) Signed-off-by: Sebastiaan van Stijn --- cli/command/service/progress/progress.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/command/service/progress/progress.go b/cli/command/service/progress/progress.go index aa8a293d21..d6f049f91b 100644 --- a/cli/command/service/progress/progress.go +++ b/cli/command/service/progress/progress.go @@ -414,7 +414,7 @@ type globalProgressUpdater struct { 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) // We don't have perfect knowledge of how many nodes meet the From ae7cd7e16afa6bb55b9ed805bf4dbf0ce1192a29 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 29 Mar 2023 16:00:17 +0200 Subject: [PATCH 07/34] cli/registry/client: AuthorizeRequest(): remove name for unused arg (revive) This method implements the interface defined in distribution, but doesn't use the argument. cli/registry/client/endpoint.go:123:69: unused-parameter: parameter 'params' seems to be unused, consider removing or renaming it as _ (revive) func (th *existingTokenHandler) AuthorizeRequest(req *http.Request, params map[string]string) error { ^ Signed-off-by: Sebastiaan van Stijn (cherry picked from commit 9252fae838de67cca89e32d740c1ed7af3c8abda) Signed-off-by: Sebastiaan van Stijn --- cli/registry/client/endpoint.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/registry/client/endpoint.go b/cli/registry/client/endpoint.go index f69c5c0dc2..31295eed33 100644 --- a/cli/registry/client/endpoint.go +++ b/cli/registry/client/endpoint.go @@ -120,7 +120,7 @@ type existingTokenHandler struct { 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)) return nil } From 0cfc19830b6dc5a3d81e3d020d3d0f7b9fda4111 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 29 Mar 2023 16:01:56 +0200 Subject: [PATCH 08/34] opts: NormalizeCapability(): fix redefinition of the built-in function (revive) opts/capabilities.go:25:2: redefines-builtin-id: redefinition of the built-in function cap (revive) cap = strings.ToUpper(strings.TrimSpace(cap)) ^ opts/capabilities.go:30:3: redefines-builtin-id: redefinition of the built-in function cap (revive) cap = "CAP_" + cap ^ Signed-off-by: Sebastiaan van Stijn (cherry picked from commit f5fad186c081dcbd77d45a5e9d4eb295e87028d9) Signed-off-by: Sebastiaan van Stijn --- opts/capabilities.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/opts/capabilities.go b/opts/capabilities.go index 8b57870376..82d071853b 100644 --- a/opts/capabilities.go +++ b/opts/capabilities.go @@ -21,15 +21,15 @@ const ( // This function only handles rudimentary formatting; no validation is performed, // as the list of available capabilities can be updated over time, thus should be // handled by the daemon. -func NormalizeCapability(cap string) string { - cap = strings.ToUpper(strings.TrimSpace(cap)) - if cap == AllCapabilities || cap == ResetCapabilities { - return cap +func NormalizeCapability(capability string) string { + capability = strings.ToUpper(strings.TrimSpace(capability)) + if capability == AllCapabilities || capability == ResetCapabilities { + return capability } - if !strings.HasPrefix(cap, "CAP_") { - cap = "CAP_" + cap + if !strings.HasPrefix(capability, "CAP_") { + capability = "CAP_" + capability } - return cap + return capability } // CapabilitiesMap normalizes the given capabilities and converts them to a map. From c0581e8a38dbf923a54c05707865aad99505a19c Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 29 Mar 2023 16:04:51 +0200 Subject: [PATCH 09/34] cli/trust: remove name for unused args (revive) These method must implements an interface, but don't use the argument. cli/trust/trust.go:85:40: unused-parameter: parameter 'u' seems to be unused, consider removing or renaming it as _ (revive) func (scs simpleCredentialStore) Basic(u *url.URL) (string, string) { ^ cli/trust/trust.go:89:47: unused-parameter: parameter 'u' seems to be unused, consider removing or renaming it as _ (revive) func (scs simpleCredentialStore) RefreshToken(u *url.URL, service string) string { ^ Signed-off-by: Sebastiaan van Stijn (cherry picked from commit a2d532819d32a5d332de9ba4889c4792007063f0) Signed-off-by: Sebastiaan van Stijn --- cli/trust/trust.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/cli/trust/trust.go b/cli/trust/trust.go index 457f799fda..0789798dbd 100644 --- a/cli/trust/trust.go +++ b/cli/trust/trust.go @@ -82,16 +82,15 @@ type simpleCredentialStore struct { 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 } -func (scs simpleCredentialStore) RefreshToken(u *url.URL, service string) string { +func (scs simpleCredentialStore) RefreshToken(*url.URL, string) string { 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 // information needed to operate on a notary repository. From dccbbfc4c760fad787a4bf69ec51f5717f62d1a7 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 30 Mar 2023 16:00:06 +0200 Subject: [PATCH 10/34] internal/test/network: FakeClient: embed interface to remove boilerplating Only a single method of the FakeClient was actually implemented (and used). This patch embeds the interface it must implement to reduce the boilerplating for not yet implemented methods. Calling any of the unimplemented methods will result in a panic, which will make it clear when they must be implemented :) This also fixes various linting errors; internal/test/network/client.go:17:37: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (c *FakeClient) NetworkConnect(ctx context.Context, networkID, container string, config *network.EndpointSettings) error { ^ internal/test/network/client.go:22:65: unused-parameter: parameter 'options' seems to be unused, consider removing or renaming it as _ (revive) func (c *FakeClient) NetworkCreate(_ context.Context, _ string, options types.NetworkCreate) (types.NetworkCreateResponse, error) { ^ internal/test/network/client.go:27:40: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (c *FakeClient) NetworkDisconnect(ctx context.Context, networkID, container string, force bool) error { ^ internal/test/network/client.go:45:53: unused-parameter: parameter 'options' seems to be unused, consider removing or renaming it as _ (revive) func (c *FakeClient) NetworkList(_ context.Context, options types.NetworkListOptions) ([]types.NetworkResource, error) { ^ internal/test/network/client.go:50:36: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (c *FakeClient) NetworkRemove(ctx context.Context, networkID string) error { ^ internal/test/network/client.go:55:55: unused-parameter: parameter 'pruneFilter' seems to be unused, consider removing or renaming it as _ (revive) func (c *FakeClient) NetworksPrune(_ context.Context, pruneFilter filters.Args) (types.NetworksPruneReport, error) { ^ Signed-off-by: Sebastiaan van Stijn (cherry picked from commit ac024a4d8b9ab74322abe50136ae4fdf3acb8ccc) Signed-off-by: Sebastiaan van Stijn --- internal/test/network/client.go | 39 ++------------------------------- 1 file changed, 2 insertions(+), 37 deletions(-) diff --git a/internal/test/network/client.go b/internal/test/network/client.go index 5a65dcb5ed..20bfa5906e 100644 --- a/internal/test/network/client.go +++ b/internal/test/network/client.go @@ -4,30 +4,15 @@ import ( "context" "github.com/docker/docker/api/types" - "github.com/docker/docker/api/types/filters" - "github.com/docker/docker/api/types/network" + "github.com/docker/docker/client" ) // FakeClient is a fake NetworkAPIClient type FakeClient struct { + client.NetworkAPIClient 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 func (c *FakeClient) NetworkInspect(ctx context.Context, networkID string, options types.NetworkInspectOptions) (types.NetworkResource, error) { if c.NetworkInspectFunc != nil { @@ -35,23 +20,3 @@ func (c *FakeClient) NetworkInspect(ctx context.Context, networkID string, optio } 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 -} From d741c64884fffd7e2079f33288e4f411f001a582 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 30 Mar 2023 16:14:47 +0200 Subject: [PATCH 11/34] cli/command/config: fakeClient: include context in fake client (revive) I could either remove the name for these contexts, or make the fake functions more accurately reflect the actual implementation (decided to go for the latter one) . cli/command/config/client_test.go:19:35: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (c *fakeClient) ConfigCreate(ctx context.Context, spec swarm.ConfigSpec) (types.ConfigCreateResponse, error) { ^ cli/command/config/client_test.go:26:43: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (c *fakeClient) ConfigInspectWithRaw(ctx context.Context, id string) (swarm.Config, []byte, error) { ^ cli/command/config/client_test.go:33:33: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (c *fakeClient) ConfigList(ctx context.Context, options types.ConfigListOptions) ([]swarm.Config, error) { ^ cli/command/config/client_test.go:40:35: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (c *fakeClient) ConfigRemove(ctx context.Context, name string) error { ^ Signed-off-by: Sebastiaan van Stijn (cherry picked from commit 66c66bdce75569f6dae69d79335a05c0eaeae641) Signed-off-by: Sebastiaan van Stijn --- cli/command/config/client_test.go | 14 +++++++------- cli/command/config/create_test.go | 11 ++++++----- cli/command/config/inspect_test.go | 21 +++++++++++---------- cli/command/config/ls_test.go | 15 ++++++++------- 4 files changed, 32 insertions(+), 29 deletions(-) diff --git a/cli/command/config/client_test.go b/cli/command/config/client_test.go index 2e19b77521..c3c938a7be 100644 --- a/cli/command/config/client_test.go +++ b/cli/command/config/client_test.go @@ -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) } diff --git a/cli/command/config/create_test.go b/cli/command/config/create_test.go index 0d1f345788..a1c5e61899 100644 --- a/cli/command/config/create_test.go +++ b/cli/command/config/create_test.go @@ -1,6 +1,7 @@ package config import ( + "context" "io" "os" "path/filepath" @@ -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 }{ { @@ -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", @@ -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) } @@ -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) } @@ -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) } diff --git a/cli/command/config/inspect_test.go b/cli/command/config/inspect_test.go index 523eba2acd..111f15bf82 100644 --- a/cli/command/config/inspect_test.go +++ b/cli/command/config/inspect_test.go @@ -1,6 +1,7 @@ package config import ( + "context" "fmt" "io" "testing" @@ -18,7 +19,7 @@ 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 }{ { @@ -26,7 +27,7 @@ func TestConfigInspectErrors(t *testing.T) { }, { 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", @@ -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 } @@ -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) } @@ -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 @@ -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 @@ -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", @@ -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", diff --git a/cli/command/config/ls_test.go b/cli/command/config/ls_test.go index 116c41bf5c..d21c2e4905 100644 --- a/cli/command/config/ls_test.go +++ b/cli/command/config/ls_test.go @@ -1,6 +1,7 @@ package config import ( + "context" "io" "testing" "time" @@ -19,7 +20,7 @@ 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 }{ { @@ -27,7 +28,7 @@ func TestConfigListErrors(t *testing.T) { 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", @@ -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"), @@ -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{ @@ -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{ @@ -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{ @@ -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{ From 6ef0757c0e2e76add0406e3f73aa6be5793b68a6 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 30 Mar 2023 16:22:06 +0200 Subject: [PATCH 12/34] cli/command/secret: fakeClient: include context in fake client (revive) I could either remove the name for these contexts, or make the fake functions more accurately reflect the actual implementation (decided to go for the latter one) cli/command/secret/client_test.go:19:35: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (c *fakeClient) SecretCreate(ctx context.Context, spec swarm.SecretSpec) (types.SecretCreateResponse, error) { ^ cli/command/secret/client_test.go:26:43: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (c *fakeClient) SecretInspectWithRaw(ctx context.Context, id string) (swarm.Secret, []byte, error) { ^ cli/command/secret/client_test.go:33:33: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (c *fakeClient) SecretList(ctx context.Context, options types.SecretListOptions) ([]swarm.Secret, error) { ^ cli/command/secret/client_test.go:40:35: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (c *fakeClient) SecretRemove(ctx context.Context, name string) error { ^ Signed-off-by: Sebastiaan van Stijn (cherry picked from commit 9dd012aa5df1c7b076f53d6cd2c328de0ea3b0f4) Signed-off-by: Sebastiaan van Stijn --- cli/command/secret/client_test.go | 16 ++++++++-------- cli/command/secret/create_test.go | 13 +++++++------ cli/command/secret/inspect_test.go | 21 +++++++++++---------- cli/command/secret/ls_test.go | 15 ++++++++------- cli/command/secret/remove_test.go | 9 +++++---- 5 files changed, 39 insertions(+), 35 deletions(-) diff --git a/cli/command/secret/client_test.go b/cli/command/secret/client_test.go index ea672fa473..efcbccfeba 100644 --- a/cli/command/secret/client_test.go +++ b/cli/command/secret/client_test.go @@ -10,36 +10,36 @@ import ( type fakeClient struct { client.Client - secretCreateFunc func(swarm.SecretSpec) (types.SecretCreateResponse, error) - secretInspectFunc func(string) (swarm.Secret, []byte, error) - secretListFunc func(types.SecretListOptions) ([]swarm.Secret, error) - secretRemoveFunc func(string) error + secretCreateFunc func(context.Context, swarm.SecretSpec) (types.SecretCreateResponse, error) + secretInspectFunc func(context.Context, string) (swarm.Secret, []byte, error) + secretListFunc func(context.Context, types.SecretListOptions) ([]swarm.Secret, error) + secretRemoveFunc func(context.Context, string) error } func (c *fakeClient) SecretCreate(ctx context.Context, spec swarm.SecretSpec) (types.SecretCreateResponse, error) { if c.secretCreateFunc != nil { - return c.secretCreateFunc(spec) + return c.secretCreateFunc(ctx, spec) } return types.SecretCreateResponse{}, nil } func (c *fakeClient) SecretInspectWithRaw(ctx context.Context, id string) (swarm.Secret, []byte, error) { if c.secretInspectFunc != nil { - return c.secretInspectFunc(id) + return c.secretInspectFunc(ctx, id) } return swarm.Secret{}, nil, nil } func (c *fakeClient) SecretList(ctx context.Context, options types.SecretListOptions) ([]swarm.Secret, error) { if c.secretListFunc != nil { - return c.secretListFunc(options) + return c.secretListFunc(ctx, options) } return []swarm.Secret{}, nil } func (c *fakeClient) SecretRemove(ctx context.Context, name string) error { if c.secretRemoveFunc != nil { - return c.secretRemoveFunc(name) + return c.secretRemoveFunc(ctx, name) } return nil } diff --git a/cli/command/secret/create_test.go b/cli/command/secret/create_test.go index 2dd65edace..6af3aa97f4 100644 --- a/cli/command/secret/create_test.go +++ b/cli/command/secret/create_test.go @@ -1,6 +1,7 @@ package secret import ( + "context" "io" "os" "path/filepath" @@ -21,7 +22,7 @@ const secretDataFile = "secret-create-with-name.golden" func TestSecretCreateErrors(t *testing.T) { testCases := []struct { args []string - secretCreateFunc func(swarm.SecretSpec) (types.SecretCreateResponse, error) + secretCreateFunc func(context.Context, swarm.SecretSpec) (types.SecretCreateResponse, error) expectedError string }{ { @@ -34,7 +35,7 @@ func TestSecretCreateErrors(t *testing.T) { }, { 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") }, expectedError: "error creating secret", @@ -66,7 +67,7 @@ func TestSecretCreateWithName(t *testing.T) { } 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) { return types.SecretCreateResponse{}, errors.Errorf("expected %+v, got %+v", expected, spec) } @@ -89,7 +90,7 @@ func TestSecretCreateWithDriver(t *testing.T) { name := "foo" 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 { return types.SecretCreateResponse{}, errors.Errorf("expected name %q, got %q", name, spec.Name) } @@ -118,7 +119,7 @@ func TestSecretCreateWithTemplatingDriver(t *testing.T) { name := "foo" 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 { return types.SecretCreateResponse{}, errors.Errorf("expected name %q, got %q", name, spec.Name) } @@ -148,7 +149,7 @@ func TestSecretCreateWithLabels(t *testing.T) { name := "foo" 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 { return types.SecretCreateResponse{}, errors.Errorf("expected name %q, got %q", name, spec.Name) } diff --git a/cli/command/secret/inspect_test.go b/cli/command/secret/inspect_test.go index e05311f2af..8f0f3e81ec 100644 --- a/cli/command/secret/inspect_test.go +++ b/cli/command/secret/inspect_test.go @@ -1,6 +1,7 @@ package secret import ( + "context" "fmt" "io" "testing" @@ -18,7 +19,7 @@ func TestSecretInspectErrors(t *testing.T) { testCases := []struct { args []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 }{ { @@ -26,7 +27,7 @@ func TestSecretInspectErrors(t *testing.T) { }, { 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") }, expectedError: "error while inspecting the secret", @@ -40,7 +41,7 @@ func TestSecretInspectErrors(t *testing.T) { }, { 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" { return *Secret(SecretName("foo")), nil, nil } @@ -68,12 +69,12 @@ func TestSecretInspectWithoutFormat(t *testing.T) { testCases := []struct { name 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", args: []string{"foo"}, - secretInspectFunc: func(name string) (swarm.Secret, []byte, error) { + secretInspectFunc: func(_ context.Context, name string) (swarm.Secret, []byte, error) { if name != "foo" { 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", 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{ "label1": "label-foo", })), nil, nil @@ -102,7 +103,7 @@ func TestSecretInspectWithoutFormat(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{ "label1": "label-foo", })), nil, nil @@ -111,7 +112,7 @@ func TestSecretInspectWithFormat(t *testing.T) { name string format string args []string - secretInspectFunc func(name string) (swarm.Secret, []byte, error) + secretInspectFunc func(_ context.Context, name string) (swarm.Secret, []byte, error) }{ { name: "simple-template", @@ -141,11 +142,11 @@ func TestSecretInspectWithFormat(t *testing.T) { func TestSecretInspectPretty(t *testing.T) { testCases := []struct { name string - secretInspectFunc func(string) (swarm.Secret, []byte, error) + secretInspectFunc func(context.Context, string) (swarm.Secret, []byte, error) }{ { name: "simple", - secretInspectFunc: func(id string) (swarm.Secret, []byte, error) { + secretInspectFunc: func(_ context.Context, id string) (swarm.Secret, []byte, error) { return *Secret( SecretLabels(map[string]string{ "lbl1": "value1", diff --git a/cli/command/secret/ls_test.go b/cli/command/secret/ls_test.go index 4c8b635fd1..c5ee26ee99 100644 --- a/cli/command/secret/ls_test.go +++ b/cli/command/secret/ls_test.go @@ -1,6 +1,7 @@ package secret import ( + "context" "io" "testing" "time" @@ -19,7 +20,7 @@ import ( func TestSecretListErrors(t *testing.T) { testCases := []struct { args []string - secretListFunc func(types.SecretListOptions) ([]swarm.Secret, error) + secretListFunc func(context.Context, types.SecretListOptions) ([]swarm.Secret, error) expectedError string }{ { @@ -27,7 +28,7 @@ func TestSecretListErrors(t *testing.T) { 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") }, expectedError: "error listing secrets", @@ -47,7 +48,7 @@ func TestSecretListErrors(t *testing.T) { func TestSecretList(t *testing.T) { 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{ *Secret(SecretID("ID-1-foo"), SecretName("1-foo"), @@ -79,7 +80,7 @@ func TestSecretList(t *testing.T) { func TestSecretListWithQuietOption(t *testing.T) { 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{ *Secret(SecretID("ID-foo"), SecretName("foo")), *Secret(SecretID("ID-bar"), SecretName("bar"), SecretLabels(map[string]string{ @@ -96,7 +97,7 @@ func TestSecretListWithQuietOption(t *testing.T) { func TestSecretListWithConfigFormat(t *testing.T) { 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{ *Secret(SecretID("ID-foo"), SecretName("foo")), *Secret(SecretID("ID-bar"), SecretName("bar"), SecretLabels(map[string]string{ @@ -115,7 +116,7 @@ func TestSecretListWithConfigFormat(t *testing.T) { func TestSecretListWithFormat(t *testing.T) { 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{ *Secret(SecretID("ID-foo"), SecretName("foo")), *Secret(SecretID("ID-bar"), SecretName("bar"), SecretLabels(map[string]string{ @@ -132,7 +133,7 @@ func TestSecretListWithFormat(t *testing.T) { func TestSecretListWithFilter(t *testing.T) { 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("lbl1=Label-bar", options.Filters.Get("label")[0])) return []swarm.Secret{ diff --git a/cli/command/secret/remove_test.go b/cli/command/secret/remove_test.go index c9f24dc22b..8600a98fd3 100644 --- a/cli/command/secret/remove_test.go +++ b/cli/command/secret/remove_test.go @@ -1,6 +1,7 @@ package secret import ( + "context" "io" "strings" "testing" @@ -14,7 +15,7 @@ import ( func TestSecretRemoveErrors(t *testing.T) { testCases := []struct { args []string - secretRemoveFunc func(string) error + secretRemoveFunc func(context.Context, string) error expectedError string }{ { @@ -23,7 +24,7 @@ func TestSecretRemoveErrors(t *testing.T) { }, { args: []string{"foo"}, - secretRemoveFunc: func(name string) error { + secretRemoveFunc: func(_ context.Context, name string) error { return errors.Errorf("error removing secret") }, expectedError: "error removing secret", @@ -45,7 +46,7 @@ func TestSecretRemoveWithName(t *testing.T) { names := []string{"foo", "bar"} var removedSecrets []string cli := test.NewFakeCli(&fakeClient{ - secretRemoveFunc: func(name string) error { + secretRemoveFunc: func(_ context.Context, name string) error { removedSecrets = append(removedSecrets, name) return nil }, @@ -62,7 +63,7 @@ func TestSecretRemoveContinueAfterError(t *testing.T) { var removedSecrets []string cli := test.NewFakeCli(&fakeClient{ - secretRemoveFunc: func(name string) error { + secretRemoveFunc: func(_ context.Context, name string) error { removedSecrets = append(removedSecrets, name) if name == "foo" { return errors.Errorf("error removing secret: %s", name) From 42e07e50fb335e58015267590406f39c44a19be6 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 30 Mar 2023 16:25:45 +0200 Subject: [PATCH 13/34] cli/command/checkpoint: fakeClient: remove name for unused arg (revive) cli/command/checkpoint/client_test.go:17:41: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (cli *fakeClient) CheckpointCreate(ctx context.Context, container string, options types.CheckpointCreateOptions) error { ^ cli/command/checkpoint/client_test.go:24:41: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (cli *fakeClient) CheckpointDelete(ctx context.Context, container string, options types.CheckpointDeleteOptions) error { ^ cli/command/checkpoint/client_test.go:31:39: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (cli *fakeClient) CheckpointList(ctx context.Context, container string, options types.CheckpointListOptions) ([]types.Checkpoint, error) { ^ Signed-off-by: Sebastiaan van Stijn (cherry picked from commit 5563c5a91d77333fbcbc7193a91ef74a5f92c6c4) Signed-off-by: Sebastiaan van Stijn --- cli/command/checkpoint/client_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cli/command/checkpoint/client_test.go b/cli/command/checkpoint/client_test.go index c8fe190e83..52dbc9115f 100644 --- a/cli/command/checkpoint/client_test.go +++ b/cli/command/checkpoint/client_test.go @@ -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) } From 63e163cf3cdf6d3abed2ccb40420c3cae2be127e Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 30 Mar 2023 16:26:53 +0200 Subject: [PATCH 14/34] cli/command/container: fakeClient: remove name for unused arg (revive) cli/command/container/client_test.go:67:41: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (f *fakeClient) ContainerExecStart(ctx context.Context, execID string, config types.ExecStartCheck) error { ^ cli/command/container/client_test.go:92:34: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (f *fakeClient) ImageCreate(ctx context.Context, parentReference string, options types.ImageCreateOptions) (io.ReadCloser, error) { ^ Signed-off-by: Sebastiaan van Stijn (cherry picked from commit 45b5676acde4a5abd7912783c80655ac0c7aa62f) Signed-off-by: Sebastiaan van Stijn --- cli/command/container/client_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cli/command/container/client_test.go b/cli/command/container/client_test.go index e8085367ef..a4c1478b43 100644 --- a/cli/command/container/client_test.go +++ b/cli/command/container/client_test.go @@ -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 } @@ -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) } From d07bce7fd2aebda91af161e99a099e000e1b59df Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 30 Mar 2023 16:27:47 +0200 Subject: [PATCH 15/34] cli/command/idresolver: fakeClient: remove name for unused arg (revive) cli/command/idresolver/client_test.go:17:43: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (cli *fakeClient) NodeInspectWithRaw(ctx context.Context, nodeID string) (swarm.Node, []byte, error) { ^ cli/command/idresolver/client_test.go:24:46: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (cli *fakeClient) ServiceInspectWithRaw(ctx context.Context, serviceID string, options types.ServiceInspectOptions) (swarm.Service, []byte, error) { ^ Signed-off-by: Sebastiaan van Stijn (cherry picked from commit 38ef40ee7a8029021039adab9639797d8b2c47a7) Signed-off-by: Sebastiaan van Stijn --- cli/command/idresolver/client_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cli/command/idresolver/client_test.go b/cli/command/idresolver/client_test.go index c53cfc6a8b..62049f4257 100644 --- a/cli/command/idresolver/client_test.go +++ b/cli/command/idresolver/client_test.go @@ -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) } From 3eee043fece6ccd106f82caa563198276e629149 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 30 Mar 2023 16:29:18 +0200 Subject: [PATCH 16/34] cli/command/image/build: remove name for unused arg (revive) cli/command/image/build/context_test.go:21:19: unused-parameter: parameter 't' seems to be unused, consider removing or renaming it as _ (revive) func prepareEmpty(t *testing.T) string { ^ Signed-off-by: Sebastiaan van Stijn (cherry picked from commit ae5a86bb8d975a9886f12f871e82a97280374861) Signed-off-by: Sebastiaan van Stijn --- cli/command/image/build/context_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/command/image/build/context_test.go b/cli/command/image/build/context_test.go index 29d48ec1d9..15686e0be4 100644 --- a/cli/command/image/build/context_test.go +++ b/cli/command/image/build/context_test.go @@ -18,7 +18,7 @@ import ( const dockerfileContents = "FROM busybox" -func prepareEmpty(t *testing.T) string { +func prepareEmpty(_ *testing.T) string { return "" } From cb6a1dfe6fc6b02c205ad056138c3969422e0714 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 30 Mar 2023 16:30:14 +0200 Subject: [PATCH 17/34] cli/command/image: fakeClient: remove name for unused arg (revive) cli/command/image/client_test.go:90:34: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (cli *fakeClient) ImageList(ctx context.Context, options types.ImageListOptions) ([]types.ImageSummary, error) { ^ Signed-off-by: Sebastiaan van Stijn (cherry picked from commit 316c4992c4c980c3d07d3115a568f1064c4f7c54) Signed-off-by: Sebastiaan van Stijn --- cli/command/image/client_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/command/image/client_test.go b/cli/command/image/client_test.go index 96e612f252..99244c7864 100644 --- a/cli/command/image/client_test.go +++ b/cli/command/image/client_test.go @@ -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) } From 9835110f8b3807daf9e32222d3247930acbcd4bc Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 30 Mar 2023 16:31:15 +0200 Subject: [PATCH 18/34] cli/command/network: fakeClient: remove name for unused arg (revive) cli/command/network/client_test.go:55:44: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (c *fakeClient) NetworkInspectWithRaw(ctx context.Context, network string, options types.NetworkInspectOptions) (types.NetworkResource, []byte, error) { ^ Signed-off-by: Sebastiaan van Stijn (cherry picked from commit 92d9e3bf6927b0bf3674db5f0d30b3272aa8fdac) Signed-off-by: Sebastiaan van Stijn --- cli/command/network/client_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/command/network/client_test.go b/cli/command/network/client_test.go index 38d942e23d..18c91e251d 100644 --- a/cli/command/network/client_test.go +++ b/cli/command/network/client_test.go @@ -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 } From e7f258feafd2f69d0c3b05fe1c8b1a3134391b69 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 30 Mar 2023 16:32:16 +0200 Subject: [PATCH 19/34] cli/command/node: fakeClient: remove name for unused arg (revive) cli/command/node/client_test.go:23:43: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (cli *fakeClient) NodeInspectWithRaw(ctx context.Context, ref string) (swarm.Node, []byte, error) { ^ cli/command/node/client_test.go:30:33: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (cli *fakeClient) NodeList(ctx context.Context, options types.NodeListOptions) ([]swarm.Node, error) { ^ cli/command/node/client_test.go:37:35: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (cli *fakeClient) NodeRemove(ctx context.Context, nodeID string, options types.NodeRemoveOptions) error { ^ cli/command/node/client_test.go:44:35: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (cli *fakeClient) NodeUpdate(ctx context.Context, nodeID string, version swarm.Version, node swarm.NodeSpec) error { ^ cli/command/node/client_test.go:51:29: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (cli *fakeClient) Info(ctx context.Context) (types.Info, error) { ^ cli/command/node/client_test.go:58:43: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (cli *fakeClient) TaskInspectWithRaw(ctx context.Context, taskID string) (swarm.Task, []byte, error) { ^ cli/command/node/client_test.go:65:33: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (cli *fakeClient) TaskList(ctx context.Context, options types.TaskListOptions) ([]swarm.Task, error) { ^ Signed-off-by: Sebastiaan van Stijn (cherry picked from commit 625988c3aa645590461531c4a0869ab255ca4920) Signed-off-by: Sebastiaan van Stijn --- cli/command/node/client_test.go | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cli/command/node/client_test.go b/cli/command/node/client_test.go index 3948c6a871..a9cf5ed972 100644 --- a/cli/command/node/client_test.go +++ b/cli/command/node/client_test.go @@ -20,49 +20,49 @@ type fakeClient struct { 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 { return cli.nodeInspectFunc() } 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 { return cli.nodeListFunc() } 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 { return cli.nodeRemoveFunc() } 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 { return cli.nodeUpdateFunc(nodeID, version, node) } 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 { return cli.infoFunc() } 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 { return cli.taskInspectFunc(taskID) } 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 { return cli.taskListFunc(options) } From e2949a133325ac710387026cc7e062de8115aa7f Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 30 Mar 2023 16:33:10 +0200 Subject: [PATCH 20/34] cli/command/plugin: fakeClient: remove name for unused arg (revive) cli/command/plugin/client_test.go:23:35: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (c *fakeClient) PluginCreate(ctx context.Context, createContext io.Reader, createOptions types.PluginCreateOptions) error { ^ cli/command/plugin/client_test.go:30:35: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (c *fakeClient) PluginEnable(ctx context.Context, name string, enableOptions types.PluginEnableOptions) error { ^ cli/command/plugin/client_test.go:37:36: unused-parameter: parameter 'context' seems to be unused, consider removing or renaming it as _ (revive) func (c *fakeClient) PluginDisable(context context.Context, name string, disableOptions types.PluginDisableOptions) error { ^ cli/command/plugin/client_test.go:44:35: unused-parameter: parameter 'context' seems to be unused, consider removing or renaming it as _ (revive) func (c *fakeClient) PluginRemove(context context.Context, name string, removeOptions types.PluginRemoveOptions) error { ^ cli/command/plugin/client_test.go:51:36: unused-parameter: parameter 'context' seems to be unused, consider removing or renaming it as _ (revive) func (c *fakeClient) PluginInstall(context context.Context, name string, installOptions types.PluginInstallOptions) (io.ReadCloser, error) { ^ cli/command/plugin/client_test.go:58:33: unused-parameter: parameter 'context' seems to be unused, consider removing or renaming it as _ (revive) func (c *fakeClient) PluginList(context context.Context, filter filters.Args) (types.PluginsListResponse, error) { ^ cli/command/plugin/client_test.go:66:43: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (c *fakeClient) PluginInspectWithRaw(ctx context.Context, name string) (*types.Plugin, []byte, error) { ^ cli/command/plugin/client_test.go:74:27: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (c *fakeClient) Info(ctx context.Context) (types.Info, error) { ^ Signed-off-by: Sebastiaan van Stijn (cherry picked from commit da3416c023ccf7d36ff4a8ed0dbc02dee7032df3) Signed-off-by: Sebastiaan van Stijn --- cli/command/plugin/client_test.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/cli/command/plugin/client_test.go b/cli/command/plugin/client_test.go index f52cefec14..57adccf4f9 100644 --- a/cli/command/plugin/client_test.go +++ b/cli/command/plugin/client_test.go @@ -20,42 +20,42 @@ type fakeClient struct { 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 { return c.pluginCreateFunc(createContext, createOptions) } 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 { return c.pluginEnableFunc(name, enableOptions) } 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 { return c.pluginDisableFunc(name, disableOptions) } 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 { return c.pluginRemoveFunc(name, removeOptions) } 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 { return c.pluginInstallFunc(name, installOptions) } 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 { return c.pluginListFunc(filter) } @@ -63,7 +63,7 @@ func (c *fakeClient) PluginList(context context.Context, filter filters.Args) (t 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 { return c.pluginInspectFunc(name) } @@ -71,6 +71,6 @@ func (c *fakeClient) PluginInspectWithRaw(ctx context.Context, name string) (*ty 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 } From 5840a39af462a190c0987b4e7bd1ea9a3db5df38 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 30 Mar 2023 16:34:04 +0200 Subject: [PATCH 21/34] cli/command/registry: fakeClient: remove name for unused arg (revive) cli/command/registry/login_test.go:37:26: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (c fakeClient) Info(ctx context.Context) (types.Info, error) { ^ cli/command/registry/login_test.go:41:35: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (c fakeClient) RegistryLogin(ctx context.Context, auth types.AuthConfig) (registrytypes.AuthenticateOKBody, error) { ^ Signed-off-by: Sebastiaan van Stijn (cherry picked from commit 5254081fd611f3e90d21a32b839c458957bdc753) Signed-off-by: Sebastiaan van Stijn --- cli/command/registry/login_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cli/command/registry/login_test.go b/cli/command/registry/login_test.go index 2f5bc94a88..483f4578ee 100644 --- a/cli/command/registry/login_test.go +++ b/cli/command/registry/login_test.go @@ -34,11 +34,11 @@ type fakeClient struct { 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 } -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 { return registrytypes.AuthenticateOKBody{}, fmt.Errorf("Invalid Username or Password") } From 67474fb865dee5e0d775cb3d366c31afbae9016f Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 30 Mar 2023 16:35:00 +0200 Subject: [PATCH 22/34] cli/command/service: fakeClient: remove name for unused arg (revive) cli/command/service/update_test.go:507:41: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (s secretAPIClientMock) SecretList(ctx context.Context, options types.SecretListOptions) ([]swarm.Secret, error) { ^ cli/command/service/update_test.go:511:43: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (s secretAPIClientMock) SecretCreate(ctx context.Context, secret swarm.SecretSpec) (types.SecretCreateResponse, error) { ^ cli/command/service/update_test.go:515:43: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (s secretAPIClientMock) SecretRemove(ctx context.Context, id string) error { ^ cli/command/service/update_test.go:519:51: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (s secretAPIClientMock) SecretInspectWithRaw(ctx context.Context, name string) (swarm.Secret, []byte, error) { ^ cli/command/service/update_test.go:523:43: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (s secretAPIClientMock) SecretUpdate(ctx context.Context, id string, version swarm.Version, secret swarm.SecretSpec) error { ^ Signed-off-by: Sebastiaan van Stijn (cherry picked from commit c69640d8c1f7cbc2eacdd42ecc64583344fe4789) Signed-off-by: Sebastiaan van Stijn --- cli/command/service/update_test.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cli/command/service/update_test.go b/cli/command/service/update_test.go index 91ba4ff381..a6e0e10679 100644 --- a/cli/command/service/update_test.go +++ b/cli/command/service/update_test.go @@ -504,23 +504,23 @@ type secretAPIClientMock struct { 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 } -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 } -func (s secretAPIClientMock) SecretRemove(ctx context.Context, id string) error { +func (s secretAPIClientMock) SecretRemove(context.Context, string) error { 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 } -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 } From be6f8b2b69daad8aee495a317db24945175bdc59 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 30 Mar 2023 16:36:36 +0200 Subject: [PATCH 23/34] cli/command/stack: fakeClient: remove name for unused arg (revive) cli/command/stack/swarm/client_test.go:46:38: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (cli *fakeClient) ServerVersion(ctx context.Context) (types.Version, error) { ^ cli/command/stack/swarm/client_test.go:57:36: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (cli *fakeClient) ServiceList(ctx context.Context, options types.ServiceListOptions) ([]swarm.Service, error) { ^ cli/command/stack/swarm/client_test.go:72:36: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (cli *fakeClient) NetworkList(ctx context.Context, options types.NetworkListOptions) ([]types.NetworkResource, error) { ^ cli/command/stack/swarm/client_test.go:87:35: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (cli *fakeClient) SecretList(ctx context.Context, options types.SecretListOptions) ([]swarm.Secret, error) { ^ cli/command/stack/swarm/client_test.go:102:35: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (cli *fakeClient) ConfigList(ctx context.Context, options types.ConfigListOptions) ([]swarm.Config, error) { ^ cli/command/stack/swarm/client_test.go:117:33: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (cli *fakeClient) TaskList(ctx context.Context, options types.TaskListOptions) ([]swarm.Task, error) { ^ cli/command/stack/swarm/client_test.go:124:33: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (cli *fakeClient) NodeList(ctx context.Context, options types.NodeListOptions) ([]swarm.Node, error) { ^ cli/command/stack/swarm/client_test.go:131:43: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (cli *fakeClient) NodeInspectWithRaw(ctx context.Context, ref string) (swarm.Node, []byte, error) { ^ cli/command/stack/swarm/client_test.go:138:38: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (cli *fakeClient) ServiceUpdate(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options types.ServiceUpdateOptions) (types.ServiceUpdateResponse, error) { ^ cli/command/stack/swarm/client_test.go:146:38: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (cli *fakeClient) ServiceRemove(ctx context.Context, serviceID string) error { ^ cli/command/stack/swarm/client_test.go:155:38: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (cli *fakeClient) NetworkRemove(ctx context.Context, networkID string) error { ^ cli/command/stack/swarm/client_test.go:164:37: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (cli *fakeClient) SecretRemove(ctx context.Context, secretID string) error { ^ cli/command/stack/swarm/client_test.go:173:37: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (cli *fakeClient) ConfigRemove(ctx context.Context, configID string) error { ^ cli/command/stack/client_test.go:46:38: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (cli *fakeClient) ServerVersion(ctx context.Context) (types.Version, error) { ^ cli/command/stack/client_test.go:57:36: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (cli *fakeClient) ServiceList(ctx context.Context, options types.ServiceListOptions) ([]swarm.Service, error) { ^ cli/command/stack/client_test.go:72:36: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (cli *fakeClient) NetworkList(ctx context.Context, options types.NetworkListOptions) ([]types.NetworkResource, error) { ^ cli/command/stack/client_test.go:87:35: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (cli *fakeClient) SecretList(ctx context.Context, options types.SecretListOptions) ([]swarm.Secret, error) { ^ cli/command/stack/client_test.go:102:35: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (cli *fakeClient) ConfigList(ctx context.Context, options types.ConfigListOptions) ([]swarm.Config, error) { ^ cli/command/stack/client_test.go:117:33: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (cli *fakeClient) TaskList(ctx context.Context, options types.TaskListOptions) ([]swarm.Task, error) { ^ cli/command/stack/client_test.go:124:33: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (cli *fakeClient) NodeList(ctx context.Context, options types.NodeListOptions) ([]swarm.Node, error) { ^ cli/command/stack/client_test.go:131:43: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (cli *fakeClient) NodeInspectWithRaw(ctx context.Context, ref string) (swarm.Node, []byte, error) { ^ cli/command/stack/client_test.go:138:38: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (cli *fakeClient) ServiceUpdate(ctx context.Context, serviceID string, version swarm.Version, service swarm.ServiceSpec, options types.ServiceUpdateOptions) (types.ServiceUpdateResponse, error) { ^ cli/command/stack/client_test.go:146:38: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (cli *fakeClient) ServiceRemove(ctx context.Context, serviceID string) error { ^ cli/command/stack/client_test.go:155:38: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (cli *fakeClient) NetworkRemove(ctx context.Context, networkID string) error { ^ cli/command/stack/client_test.go:164:37: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (cli *fakeClient) SecretRemove(ctx context.Context, secretID string) error { ^ cli/command/stack/client_test.go:173:37: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (cli *fakeClient) ConfigRemove(ctx context.Context, configID string) error { ^ cli/command/stack/client_test.go:182:46: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (cli *fakeClient) ServiceInspectWithRaw(ctx context.Context, serviceID string, opts types.ServiceInspectOptions) (swarm.Service, []byte, error) { ^ Signed-off-by: Sebastiaan van Stijn (cherry picked from commit b0d0b0efcbfe1160ef91e705559c507514af0f64) Signed-off-by: Sebastiaan van Stijn --- cli/command/stack/client_test.go | 28 +++++++++++++------------- cli/command/stack/swarm/client_test.go | 26 ++++++++++++------------ 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/cli/command/stack/client_test.go b/cli/command/stack/client_test.go index a4f95cf308..6a2d0a900a 100644 --- a/cli/command/stack/client_test.go +++ b/cli/command/stack/client_test.go @@ -43,7 +43,7 @@ type fakeClient struct { 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{ Version: "docker-dev", APIVersion: api.DefaultVersion, @@ -54,7 +54,7 @@ func (cli *fakeClient) ClientVersion() string { 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 { return cli.serviceListFunc(options) } @@ -69,7 +69,7 @@ func (cli *fakeClient) ServiceList(ctx context.Context, options types.ServiceLis 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 { return cli.networkListFunc(options) } @@ -84,7 +84,7 @@ func (cli *fakeClient) NetworkList(ctx context.Context, options types.NetworkLis 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 { return cli.secretListFunc(options) } @@ -99,7 +99,7 @@ func (cli *fakeClient) SecretList(ctx context.Context, options types.SecretListO 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 { return cli.configListFunc(options) } @@ -114,28 +114,28 @@ func (cli *fakeClient) ConfigList(ctx context.Context, options types.ConfigListO 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 { return cli.taskListFunc(options) } 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 { return cli.nodeListFunc(options) } 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 { return cli.nodeInspectWithRaw(ref) } 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 { 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 } -func (cli *fakeClient) ServiceRemove(ctx context.Context, serviceID string) error { +func (cli *fakeClient) ServiceRemove(_ context.Context, serviceID string) error { if cli.serviceRemoveFunc != nil { return cli.serviceRemoveFunc(serviceID) } @@ -152,7 +152,7 @@ func (cli *fakeClient) ServiceRemove(ctx context.Context, serviceID string) erro 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 { return cli.networkRemoveFunc(networkID) } @@ -161,7 +161,7 @@ func (cli *fakeClient) NetworkRemove(ctx context.Context, networkID string) erro 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 { return cli.secretRemoveFunc(secretID) } @@ -170,7 +170,7 @@ func (cli *fakeClient) SecretRemove(ctx context.Context, secretID string) error 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 { return cli.configRemoveFunc(configID) } @@ -179,7 +179,7 @@ func (cli *fakeClient) ConfigRemove(ctx context.Context, configID string) error 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{ ID: serviceID, Spec: swarm.ServiceSpec{ diff --git a/cli/command/stack/swarm/client_test.go b/cli/command/stack/swarm/client_test.go index 7f9375e99f..c0fd6a83d0 100644 --- a/cli/command/stack/swarm/client_test.go +++ b/cli/command/stack/swarm/client_test.go @@ -43,7 +43,7 @@ type fakeClient struct { 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{ Version: "docker-dev", APIVersion: api.DefaultVersion, @@ -54,7 +54,7 @@ func (cli *fakeClient) ClientVersion() string { 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 { return cli.serviceListFunc(options) } @@ -69,7 +69,7 @@ func (cli *fakeClient) ServiceList(ctx context.Context, options types.ServiceLis 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 { return cli.networkListFunc(options) } @@ -84,7 +84,7 @@ func (cli *fakeClient) NetworkList(ctx context.Context, options types.NetworkLis 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 { return cli.secretListFunc(options) } @@ -99,7 +99,7 @@ func (cli *fakeClient) SecretList(ctx context.Context, options types.SecretListO 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 { return cli.configListFunc(options) } @@ -114,28 +114,28 @@ func (cli *fakeClient) ConfigList(ctx context.Context, options types.ConfigListO 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 { return cli.taskListFunc(options) } 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 { return cli.nodeListFunc(options) } 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 { return cli.nodeInspectWithRaw(ref) } 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 { 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 } -func (cli *fakeClient) ServiceRemove(ctx context.Context, serviceID string) error { +func (cli *fakeClient) ServiceRemove(_ context.Context, serviceID string) error { if cli.serviceRemoveFunc != nil { return cli.serviceRemoveFunc(serviceID) } @@ -152,7 +152,7 @@ func (cli *fakeClient) ServiceRemove(ctx context.Context, serviceID string) erro 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 { return cli.networkRemoveFunc(networkID) } @@ -161,7 +161,7 @@ func (cli *fakeClient) NetworkRemove(ctx context.Context, networkID string) erro 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 { return cli.secretRemoveFunc(secretID) } @@ -170,7 +170,7 @@ func (cli *fakeClient) SecretRemove(ctx context.Context, secretID string) error 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 { return cli.configRemoveFunc(configID) } From fec554c357ee45ee6ad7a1c5f9ff612426ea4c32 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 30 Mar 2023 16:38:10 +0200 Subject: [PATCH 24/34] cli/command/swarm: fakeClient: remove name for unused arg (revive) cli/command/swarm/ipnet_slice_test.go:13:14: unused-parameter: parameter 'ip' seems to be unused, consider removing or renaming it as _ (revive) func getCIDR(ip net.IP, cidr *net.IPNet, err error) net.IPNet { ^ cli/command/swarm/client_test.go:24:29: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (cli *fakeClient) Info(ctx context.Context) (types.Info, error) { ^ cli/command/swarm/client_test.go:31:43: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (cli *fakeClient) NodeInspectWithRaw(ctx context.Context, ref string) (swarm.Node, []byte, error) { ^ cli/command/swarm/client_test.go:38:34: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (cli *fakeClient) SwarmInit(ctx context.Context, req swarm.InitRequest) (string, error) { ^ cli/command/swarm/client_test.go:45:37: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (cli *fakeClient) SwarmInspect(ctx context.Context) (swarm.Swarm, error) { ^ cli/command/swarm/client_test.go:52:42: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (cli *fakeClient) SwarmGetUnlockKey(ctx context.Context) (types.SwarmUnlockKeyResponse, error) { ^ cli/command/swarm/client_test.go:59:34: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (cli *fakeClient) SwarmJoin(ctx context.Context, req swarm.JoinRequest) error { ^ cli/command/swarm/client_test.go:66:35: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (cli *fakeClient) SwarmLeave(ctx context.Context, force bool) error { ^ cli/command/swarm/client_test.go:73:36: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (cli *fakeClient) SwarmUpdate(ctx context.Context, version swarm.Version, swarm swarm.Spec, flags swarm.UpdateFlags) error { ^ cli/command/swarm/client_test.go:80:36: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (cli *fakeClient) SwarmUnlock(ctx context.Context, req swarm.UnlockRequest) error { ^ Signed-off-by: Sebastiaan van Stijn (cherry picked from commit 40a51d55432045ecc4ad6afb9e839853e870d8b0) Signed-off-by: Sebastiaan van Stijn --- cli/command/swarm/client_test.go | 18 +++++++++--------- cli/command/swarm/ipnet_slice_test.go | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/cli/command/swarm/client_test.go b/cli/command/swarm/client_test.go index 8695c89518..e116ed0b16 100644 --- a/cli/command/swarm/client_test.go +++ b/cli/command/swarm/client_test.go @@ -21,63 +21,63 @@ type fakeClient struct { 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 { return cli.infoFunc() } 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 { return cli.nodeInspectFunc() } 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 { return cli.swarmInitFunc() } 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 { return cli.swarmInspectFunc() } 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 { return cli.swarmGetUnlockKeyFunc() } 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 { return cli.swarmJoinFunc() } return nil } -func (cli *fakeClient) SwarmLeave(ctx context.Context, force bool) error { +func (cli *fakeClient) SwarmLeave(context.Context, bool) error { if cli.swarmLeaveFunc != nil { return cli.swarmLeaveFunc() } 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 { return cli.swarmUpdateFunc(swarm, flags) } 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 { return cli.swarmUnlockFunc(req) } diff --git a/cli/command/swarm/ipnet_slice_test.go b/cli/command/swarm/ipnet_slice_test.go index 36275b9891..3f28466ea1 100644 --- a/cli/command/swarm/ipnet_slice_test.go +++ b/cli/command/swarm/ipnet_slice_test.go @@ -10,7 +10,7 @@ import ( ) // 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 } From 93772a590df8506200b10a6c4da773b892479a0b Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 30 Mar 2023 16:39:06 +0200 Subject: [PATCH 25/34] cli/command/task: fakeClient: remove name for unused arg (revive) cli/command/task/client_test.go:17:43: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (cli *fakeClient) NodeInspectWithRaw(ctx context.Context, ref string) (swarm.Node, []byte, error) { ^ cli/command/task/client_test.go:24:46: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (cli *fakeClient) ServiceInspectWithRaw(ctx context.Context, ref string, options types.ServiceInspectOptions) (swarm.Service, []byte, error) { ^ Signed-off-by: Sebastiaan van Stijn (cherry picked from commit b32b28041d94af28a03c3424457fde811119ae4c) Signed-off-by: Sebastiaan van Stijn --- cli/command/task/client_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cli/command/task/client_test.go b/cli/command/task/client_test.go index 9aa849779a..3c5129e261 100644 --- a/cli/command/task/client_test.go +++ b/cli/command/task/client_test.go @@ -14,14 +14,14 @@ type fakeClient struct { 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 { return cli.nodeInspectWithRaw(ref) } 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 { return cli.serviceInspectWithRaw(ref, options) } From 8cbad756d99c5f6d8d5252317cdc8977a87eb2b4 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 30 Mar 2023 16:40:07 +0200 Subject: [PATCH 26/34] cli/command/trust: fakeClient: remove name for unused arg (revive) cli/command/trust/inspect_pretty_test.go:30:27: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (c *fakeClient) Info(ctx context.Context) (types.Info, error) { ^ cli/command/trust/inspect_pretty_test.go:34:42: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (c *fakeClient) ImageInspectWithRaw(ctx context.Context, imageID string) (types.ImageInspect, []byte, error) { ^ cli/command/trust/inspect_pretty_test.go:38:32: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (c *fakeClient) ImagePush(ctx context.Context, image string, options types.ImagePushOptions) (io.ReadCloser, error) { ^ Signed-off-by: Sebastiaan van Stijn (cherry picked from commit 546cf6d985687046e8f026df550390f24d0db053) Signed-off-by: Sebastiaan van Stijn --- cli/command/trust/inspect_pretty_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cli/command/trust/inspect_pretty_test.go b/cli/command/trust/inspect_pretty_test.go index 4c6e3ffca9..2ccfd927d8 100644 --- a/cli/command/trust/inspect_pretty_test.go +++ b/cli/command/trust/inspect_pretty_test.go @@ -27,15 +27,15 @@ type fakeClient struct { 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 } -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 } -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 } From b298f8f2cd2a013365e07651396817846cf31fc4 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 30 Mar 2023 16:41:08 +0200 Subject: [PATCH 27/34] cli/command/volume: remove name for unused arg (revive) cli/command/volume/prune_test.go:113:22: unused-parameter: parameter 'args' seems to be unused, consider removing or renaming it as _ (revive) func simplePruneFunc(args filters.Args) (types.VolumesPruneReport, error) { ^ Signed-off-by: Sebastiaan van Stijn (cherry picked from commit 607f290f6572cf13f3623c253058158df0f42221) Signed-off-by: Sebastiaan van Stijn --- cli/command/volume/prune_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/command/volume/prune_test.go b/cli/command/volume/prune_test.go index c02a3be0b6..5a0a2ba5b3 100644 --- a/cli/command/volume/prune_test.go +++ b/cli/command/volume/prune_test.go @@ -169,7 +169,7 @@ func TestVolumePrunePromptNo(t *testing.T) { } } -func simplePruneFunc(args filters.Args) (types.VolumesPruneReport, error) { +func simplePruneFunc(filters.Args) (types.VolumesPruneReport, error) { return types.VolumesPruneReport{ VolumesDeleted: []string{ "foo", "bar", "baz", From dcec47bf2b75777b13dd95b0d019870b33b44960 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 30 Mar 2023 16:41:55 +0200 Subject: [PATCH 28/34] cli/compose/convert: fakeClient: remove name for unused arg (revive) cli/compose/convert/service_test.go:599:33: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (c *fakeClient) SecretList(ctx context.Context, options types.SecretListOptions) ([]swarm.Secret, error) { ^ cli/compose/convert/service_test.go:606:33: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func (c *fakeClient) ConfigList(ctx context.Context, options types.ConfigListOptions) ([]swarm.Config, error) { ^ Signed-off-by: Sebastiaan van Stijn (cherry picked from commit 6355bcee66c8e2bc3098f40aca8d9badae86a735) Signed-off-by: Sebastiaan van Stijn --- cli/compose/convert/service_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cli/compose/convert/service_test.go b/cli/compose/convert/service_test.go index 2cee55dc4e..7a23548e9e 100644 --- a/cli/compose/convert/service_test.go +++ b/cli/compose/convert/service_test.go @@ -596,14 +596,14 @@ type fakeClient struct { 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 { return c.secretListFunc(options) } 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 { return c.configListFunc(options) } From 28f1b586f63dc0bc867cc17c6e4f0f273054aea6 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 30 Mar 2023 16:43:03 +0200 Subject: [PATCH 29/34] cli/compose/schema: remove name for unused arg (revive) cli/compose/schema/schema.go:20:44: unused-parameter: parameter 'input' seems to be unused, consider removing or renaming it as _ (revive) func (checker portsFormatChecker) IsFormat(input interface{}) bool { ^ Signed-off-by: Sebastiaan van Stijn (cherry picked from commit 7c8680c69b2c12aec072636467b48fe79b11af96) Signed-off-by: Sebastiaan van Stijn --- cli/compose/schema/schema.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/compose/schema/schema.go b/cli/compose/schema/schema.go index 9d2a58e8b3..c7786f48fb 100644 --- a/cli/compose/schema/schema.go +++ b/cli/compose/schema/schema.go @@ -17,7 +17,7 @@ const ( type portsFormatChecker struct{} -func (checker portsFormatChecker) IsFormat(input interface{}) bool { +func (checker portsFormatChecker) IsFormat(_ interface{}) bool { // TODO: implement this return true } From 3b389dd27354e8895ed3f3fc1c3f6fca79173318 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 30 Mar 2023 16:44:02 +0200 Subject: [PATCH 30/34] cli/config/configfile: mockNativeStore: remove name for unused arg (revive) cli/config/configfile/file_test.go:189:33: unused-parameter: parameter 'authConfig' seems to be unused, consider removing or renaming it as _ (revive) func (c *mockNativeStore) Store(authConfig types.AuthConfig) error { ^ Signed-off-by: Sebastiaan van Stijn (cherry picked from commit dd6ede210931a7ce4cc3123bb729fb5dfc788840) Signed-off-by: Sebastiaan van Stijn --- cli/config/configfile/file_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/config/configfile/file_test.go b/cli/config/configfile/file_test.go index b36cb479fb..74a0317d5e 100644 --- a/cli/config/configfile/file_test.go +++ b/cli/config/configfile/file_test.go @@ -186,7 +186,7 @@ func (c *mockNativeStore) GetAll() (map[string]types.AuthConfig, error) { return c.authConfigs, nil } -func (c *mockNativeStore) Store(authConfig types.AuthConfig) error { +func (c *mockNativeStore) Store(_ types.AuthConfig) error { return nil } From 0d34fe7fb2f0db70da2b5505451249477e60631b Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 30 Mar 2023 16:45:07 +0200 Subject: [PATCH 31/34] cli/connhelper/commandconn: remove name for unused arg (revive) cli/connhelper/commandconn/commandconn.go:35:10: unused-parameter: parameter 'ctx' seems to be unused, consider removing or renaming it as _ (revive) func New(ctx context.Context, cmd string, args ...string) (net.Conn, error) { ^ Signed-off-by: Sebastiaan van Stijn (cherry picked from commit 90380d95766544d2c259563dd807518c42c003f9) Signed-off-by: Sebastiaan van Stijn --- cli/connhelper/commandconn/commandconn.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/connhelper/commandconn/commandconn.go b/cli/connhelper/commandconn/commandconn.go index a0b035c92a..202ddb84cc 100644 --- a/cli/connhelper/commandconn/commandconn.go +++ b/cli/connhelper/commandconn/commandconn.go @@ -32,7 +32,7 @@ import ( ) // 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 ( c commandConn err error From 974dcfd6546bccf1bafc023c4653343647be2524 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 30 Mar 2023 16:46:42 +0200 Subject: [PATCH 32/34] internal/test/notary: remove name for unused arg (revive) internal/test/notary/client.go:16:33: unused-parameter: parameter 'imgRefAndAuth' seems to be unused, consider removing or renaming it as _ (revive) func GetOfflineNotaryRepository(imgRefAndAuth trust.ImageRefAndAuth, actions []string) (client.Repository, error) { ^ internal/test/notary/client.go:25:45: unused-parameter: parameter 'rootKeyIDs' seems to be unused, consider removing or renaming it as _ (revive) func (o OfflineNotaryRepository) Initialize(rootKeyIDs []string, serverManagedRoles ...data.RoleName) error { ^ internal/test/notary/client.go:30:60: unused-parameter: parameter 'rootKeyIDs' seems to be unused, consider removing or renaming it as _ (revive) func (o OfflineNotaryRepository) InitializeWithCertificate(rootKeyIDs []string, rootCerts []data.PublicKey, serverManagedRoles ...data.RoleName) error { ^ internal/test/notary/client.go:42:44: unused-parameter: parameter 'target' seems to be unused, consider removing or renaming it as _ (revive) func (o OfflineNotaryRepository) AddTarget(target *client.Target, roles ...data.RoleName) error { ^ internal/test/notary/client.go:48:47: unused-parameter: parameter 'targetName' seems to be unused, consider removing or renaming it as _ (revive) func (o OfflineNotaryRepository) RemoveTarget(targetName string, roles ...data.RoleName) error { ^ internal/test/notary/client.go:54:46: unused-parameter: parameter 'roles' seems to be unused, consider removing or renaming it as _ (revive) func (o OfflineNotaryRepository) ListTargets(roles ...data.RoleName) ([]*client.TargetWithRole, error) { ^ internal/test/notary/client.go:59:50: unused-parameter: parameter 'name' seems to be unused, consider removing or renaming it as _ (revive) func (o OfflineNotaryRepository) GetTargetByName(name string, roles ...data.RoleName) (*client.TargetWithRole, error) { ^ internal/test/notary/client.go:65:61: unused-parameter: parameter 'name' seems to be unused, consider removing or renaming it as _ (revive) func (o OfflineNotaryRepository) GetAllTargetMetadataByName(name string) ([]client.TargetSignedStruct, error) { ^ internal/test/notary/client.go:85:48: unused-parameter: parameter 'name' seems to be unused, consider removing or renaming it as _ (revive) func (o OfflineNotaryRepository) AddDelegation(name data.RoleName, delegationKeys []data.PublicKey, paths []string) error { ^ internal/test/notary/client.go:90:59: unused-parameter: parameter 'name' seems to be unused, consider removing or renaming it as _ (revive) func (o OfflineNotaryRepository) AddDelegationRoleAndKeys(name data.RoleName, delegationKeys []data.PublicKey) error { ^ internal/test/notary/client.go:95:53: unused-parameter: parameter 'name' seems to be unused, consider removing or renaming it as _ (revive) func (o OfflineNotaryRepository) AddDelegationPaths(name data.RoleName, paths []string) error { ^ internal/test/notary/client.go:100:63: unused-parameter: parameter 'name' seems to be unused, consider removing or renaming it as _ (revive) func (o OfflineNotaryRepository) RemoveDelegationKeysAndPaths(name data.RoleName, keyIDs, paths []string) error { ^ internal/test/notary/client.go:105:55: unused-parameter: parameter 'name' seems to be unused, consider removing or renaming it as _ (revive) func (o OfflineNotaryRepository) RemoveDelegationRole(name data.RoleName) error { ^ internal/test/notary/client.go:110:56: unused-parameter: parameter 'name' seems to be unused, consider removing or renaming it as _ (revive) func (o OfflineNotaryRepository) RemoveDelegationPaths(name data.RoleName, paths []string) error { ^ internal/test/notary/client.go:115:55: unused-parameter: parameter 'name' seems to be unused, consider removing or renaming it as _ (revive) func (o OfflineNotaryRepository) RemoveDelegationKeys(name data.RoleName, keyIDs []string) error { ^ internal/test/notary/client.go:120:55: unused-parameter: parameter 'name' seems to be unused, consider removing or renaming it as _ (revive) func (o OfflineNotaryRepository) ClearDelegationPaths(name data.RoleName) error { ^ internal/test/notary/client.go:126:42: unused-parameter: parameter 'roles' seems to be unused, consider removing or renaming it as _ (revive) func (o OfflineNotaryRepository) Witness(roles ...data.RoleName) ([]data.RoleName, error) { ^ internal/test/notary/client.go:131:44: unused-parameter: parameter 'role' seems to be unused, consider removing or renaming it as _ (revive) func (o OfflineNotaryRepository) RotateKey(role data.RoleName, serverManagesKey bool, keyList []string) error { ^ internal/test/notary/client.go:142:52: unused-parameter: parameter 'version' seems to be unused, consider removing or renaming it as _ (revive) func (o OfflineNotaryRepository) SetLegacyVersions(version int) {} ^ internal/test/notary/client.go:150:39: unused-parameter: parameter 'imgRefAndAuth' seems to be unused, consider removing or renaming it as _ (revive) func GetUninitializedNotaryRepository(imgRefAndAuth trust.ImageRefAndAuth, actions []string) (client.Repository, error) { ^ internal/test/notary/client.go:163:51: unused-parameter: parameter 'rootKeyIDs' seems to be unused, consider removing or renaming it as _ (revive) func (u UninitializedNotaryRepository) Initialize(rootKeyIDs []string, serverManagedRoles ...data.RoleName) error { ^ internal/test/notary/client.go:168:66: unused-parameter: parameter 'rootKeyIDs' seems to be unused, consider removing or renaming it as _ (revive) func (u UninitializedNotaryRepository) InitializeWithCertificate(rootKeyIDs []string, rootCerts []data.PublicKey, serverManagedRoles ...data.RoleName) error { ^ internal/test/notary/client.go:180:52: unused-parameter: parameter 'roles' seems to be unused, consider removing or renaming it as _ (revive) func (u UninitializedNotaryRepository) ListTargets(roles ...data.RoleName) ([]*client.TargetWithRole, error) { ^ internal/test/notary/client.go:185:56: unused-parameter: parameter 'name' seems to be unused, consider removing or renaming it as _ (revive) func (u UninitializedNotaryRepository) GetTargetByName(name string, roles ...data.RoleName) (*client.TargetWithRole, error) { ^ internal/test/notary/client.go:191:67: unused-parameter: parameter 'name' seems to be unused, consider removing or renaming it as _ (revive) func (u UninitializedNotaryRepository) GetAllTargetMetadataByName(name string) ([]client.TargetSignedStruct, error) { ^ internal/test/notary/client.go:206:50: unused-parameter: parameter 'role' seems to be unused, consider removing or renaming it as _ (revive) func (u UninitializedNotaryRepository) RotateKey(role data.RoleName, serverManagesKey bool, keyList []string) error { ^ internal/test/notary/client.go:211:38: unused-parameter: parameter 'imgRefAndAuth' seems to be unused, consider removing or renaming it as _ (revive) func GetEmptyTargetsNotaryRepository(imgRefAndAuth trust.ImageRefAndAuth, actions []string) (client.Repository, error) { ^ internal/test/notary/client.go:223:50: unused-parameter: parameter 'rootKeyIDs' seems to be unused, consider removing or renaming it as _ (revive) func (e EmptyTargetsNotaryRepository) Initialize(rootKeyIDs []string, serverManagedRoles ...data.RoleName) error { ^ internal/test/notary/client.go:228:65: unused-parameter: parameter 'rootKeyIDs' seems to be unused, consider removing or renaming it as _ (revive) func (e EmptyTargetsNotaryRepository) InitializeWithCertificate(rootKeyIDs []string, rootCerts []data.PublicKey, serverManagedRoles ...data.RoleName) error { ^ internal/test/notary/client.go:240:51: unused-parameter: parameter 'roles' seems to be unused, consider removing or renaming it as _ (revive) func (e EmptyTargetsNotaryRepository) ListTargets(roles ...data.RoleName) ([]*client.TargetWithRole, error) { ^ internal/test/notary/client.go:245:68: unused-parameter: parameter 'roles' seems to be unused, consider removing or renaming it as _ (revive) func (e EmptyTargetsNotaryRepository) GetTargetByName(name string, roles ...data.RoleName) (*client.TargetWithRole, error) { ^ internal/test/notary/client.go:284:49: unused-parameter: parameter 'role' seems to be unused, consider removing or renaming it as _ (revive) func (e EmptyTargetsNotaryRepository) RotateKey(role data.RoleName, serverManagesKey bool, keyList []string) error { ^ internal/test/notary/client.go:289:32: unused-parameter: parameter 'imgRefAndAuth' seems to be unused, consider removing or renaming it as _ (revive) func GetLoadedNotaryRepository(imgRefAndAuth trust.ImageRefAndAuth, actions []string) (client.Repository, error) { ^ internal/test/notary/client.go:509:45: unused-parameter: parameter 'imgRefAndAuth' seems to be unused, consider removing or renaming it as _ (revive) func GetLoadedWithNoSignersNotaryRepository(imgRefAndAuth trust.ImageRefAndAuth, actions []string) (client.Repository, error) { ^ internal/test/notary/client.go:532:75: unused-parameter: parameter 'roles' seems to be unused, consider removing or renaming it as _ (revive) func (l LoadedWithNoSignersNotaryRepository) GetTargetByName(name string, roles ...data.RoleName) (*client.TargetWithRole, error) { ^ Signed-off-by: Sebastiaan van Stijn (cherry picked from commit 20a70cb5304966a14076aa03c82e87d496a77b1b) Signed-off-by: Sebastiaan van Stijn --- internal/test/notary/client.go | 70 +++++++++++++++++----------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/internal/test/notary/client.go b/internal/test/notary/client.go index ef7e2824e5..b6c6db0e58 100644 --- a/internal/test/notary/client.go +++ b/internal/test/notary/client.go @@ -13,7 +13,7 @@ import ( ) // 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 } @@ -22,12 +22,12 @@ type OfflineNotaryRepository struct{} // Initialize creates a new repository by using rootKey as the root Key for the // TUF repository. -func (o OfflineNotaryRepository) Initialize(rootKeyIDs []string, serverManagedRoles ...data.RoleName) error { +func (o OfflineNotaryRepository) Initialize([]string, ...data.RoleName) error { return storage.ErrOffline{} } // 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{} } @@ -39,30 +39,30 @@ func (o OfflineNotaryRepository) Publish() error { // AddTarget creates new changelist entries to add a target to the given roles // 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 } // RemoveTarget creates new changelist entries to remove a target from the given // 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 } // ListTargets lists all targets for the current repository. The list of // 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{} } // 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{} } // 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. -func (o OfflineNotaryRepository) GetAllTargetMetadataByName(name string) ([]client.TargetSignedStruct, error) { +func (o OfflineNotaryRepository) GetAllTargetMetadataByName(string) ([]client.TargetSignedStruct, error) { 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. -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 } // 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 } // 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 } // 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 } // 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 } // 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 } // 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 } // 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 } // Witness creates change objects to witness (i.e. re-sign) the given // 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 } // 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{} } @@ -139,7 +139,7 @@ func (o OfflineNotaryRepository) GetCryptoService() signed.CryptoService { // SetLegacyVersions allows the number of legacy versions of the root // 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 func (o OfflineNotaryRepository) GetGUN() data.GUN { @@ -147,7 +147,7 @@ func (o OfflineNotaryRepository) GetGUN() data.GUN { } // 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 } @@ -160,12 +160,12 @@ type UninitializedNotaryRepository struct { // Initialize creates a new repository by using rootKey as the root Key for the // TUF repository. -func (u UninitializedNotaryRepository) Initialize(rootKeyIDs []string, serverManagedRoles ...data.RoleName) error { +func (u UninitializedNotaryRepository) Initialize([]string, ...data.RoleName) error { return client.ErrRepositoryNotExist{} } // 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{} } @@ -177,18 +177,18 @@ func (u UninitializedNotaryRepository) Publish() error { // ListTargets lists all targets for the current repository. The list of // 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{} } // 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{} } // 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. -func (u UninitializedNotaryRepository) GetAllTargetMetadataByName(name string) ([]client.TargetSignedStruct, error) { +func (u UninitializedNotaryRepository) GetAllTargetMetadataByName(string) ([]client.TargetSignedStruct, error) { 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 -func (u UninitializedNotaryRepository) RotateKey(role data.RoleName, serverManagesKey bool, keyList []string) error { +func (u UninitializedNotaryRepository) RotateKey(data.RoleName, bool, []string) error { return client.ErrRepositoryNotExist{} } // 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 } @@ -220,12 +220,12 @@ type EmptyTargetsNotaryRepository struct { // Initialize creates a new repository by using rootKey as the root Key for the // TUF repository. -func (e EmptyTargetsNotaryRepository) Initialize(rootKeyIDs []string, serverManagedRoles ...data.RoleName) error { +func (e EmptyTargetsNotaryRepository) Initialize([]string, ...data.RoleName) error { return nil } // 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 } @@ -237,12 +237,12 @@ func (e EmptyTargetsNotaryRepository) Publish() error { // ListTargets lists all targets for the current repository. The list of // 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 } // 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) } @@ -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 -func (e EmptyTargetsNotaryRepository) RotateKey(role data.RoleName, serverManagesKey bool, keyList []string) error { +func (e EmptyTargetsNotaryRepository) RotateKey(data.RoleName, bool, []string) error { return nil } // 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 } @@ -506,7 +506,7 @@ func (l LoadedNotaryRepository) GetCryptoService() signed.CryptoService { } // 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 } @@ -529,7 +529,7 @@ func (l LoadedWithNoSignersNotaryRepository) ListTargets(roles ...data.RoleName) } // 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 { return &client.TargetWithRole{Target: loadedGreenTarget, Role: data.CanonicalTargetsRole}, nil } From 73624c4bdee2db282a615c68f4bbe77b0537eb84 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 30 Mar 2023 16:47:41 +0200 Subject: [PATCH 33/34] internal/test: FakeCli: remove name for unused arg (revive) internal/test/cli.go:184:34: unused-parameter: parameter 'insecure' seems to be unused, consider removing or renaming it as _ (revive) func (c *FakeCli) RegistryClient(insecure bool) registryclient.RegistryClient { ^ Signed-off-by: Sebastiaan van Stijn (cherry picked from commit 399ded9b98c33201a0ae32f7b1b42f2582a9797f) Signed-off-by: Sebastiaan van Stijn --- internal/test/cli.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/test/cli.go b/internal/test/cli.go index db800bec8c..11d674d857 100644 --- a/internal/test/cli.go +++ b/internal/test/cli.go @@ -181,7 +181,7 @@ func (c *FakeCli) ManifestStore() manifeststore.Store { } // 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 } From d170759bcde8230d2f060a476fbcc96419f8c0d4 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Tue, 28 Mar 2023 20:13:44 +0200 Subject: [PATCH 34/34] update golangci-lint to v1.52.2 Signed-off-by: Sebastiaan van Stijn (cherry picked from commit b8747b0f91dd46679748b0e94eb74b566a4a966c) Signed-off-by: Sebastiaan van Stijn --- dockerfiles/Dockerfile.lint | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dockerfiles/Dockerfile.lint b/dockerfiles/Dockerfile.lint index e687969605..e229bf7146 100644 --- a/dockerfiles/Dockerfile.lint +++ b/dockerfiles/Dockerfile.lint @@ -2,7 +2,7 @@ ARG GO_VERSION=1.19.10 ARG ALPINE_VERSION=3.17 -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