Commit Graph

1738 Commits

Author SHA1 Message Date
Cory Snider 069e27c180 linting: format the codebase with gofumpt
...to appease the linter.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2024-09-04 16:23:34 -04:00
Sebastiaan van Stijn 5e5ccaa829 cli/command/image/build: fix nosec comment
Looks like it's broken, so use a blanket "nolint:gosec" instead;

    cli/command/image/build/context.go:238:17: G107: Potential HTTP request made with variable url (gosec)
        if resp, err = http.Get(url); err != nil {
                        ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit df474d5176)
Signed-off-by: Cory Snider <csnider@mirantis.com>
2024-09-03 19:35:23 -04:00
Sebastiaan van Stijn ac722bb368 linting: fmt.Sprintf can be replaced with string concatenation (perfsprint)
cli/registry/client/endpoint.go:128:34: fmt.Sprintf can be replaced with string concatenation (perfsprint)
        req.Header.Set("Authorization", fmt.Sprintf("Bearer %s", th.token))
                                        ^
    cli/command/telemetry_docker.go:88:14: fmt.Sprintf can be replaced with string concatenation (perfsprint)
            endpoint = fmt.Sprintf("unix://%s", path.Join(u.Host, u.Path))
                       ^
    cli/command/cli_test.go:195:47: fmt.Sprintf can be replaced with string concatenation (perfsprint)
        opts := &flags.ClientOptions{Hosts: []string{fmt.Sprintf("unix://%s", socket)}}
                                                     ^

    cli/command/registry_test.go:59:24: fmt.Sprintf can be replaced with string concatenation (perfsprint)
                inputServerAddress: fmt.Sprintf("https://%s", testAuthConfigs[1].ServerAddress),
                                    ^
    cli/command/container/opts_test.go:338:35: fmt.Sprintf can be replaced with string concatenation (perfsprint)
            if config, _, _ := mustParse(t, fmt.Sprintf("--hostname=%s", hostname)); config.Hostname != expectedHostname {
                                            ^
    cli/command/context/options.go:79:24: fmt.Sprintf can be replaced with string concatenation (perfsprint)
                errs = append(errs, fmt.Sprintf("%s: unrecognized config key", k))
                                    ^
    cli/command/image/build.go:461:68: fmt.Sprintf can be replaced with string concatenation (perfsprint)
                    line = dockerfileFromLinePattern.ReplaceAllLiteralString(line, fmt.Sprintf("FROM %s", reference.FamiliarString(trustedRef)))
                                                                                   ^
    cli/command/image/remove_test.go:21:9: fmt.Sprintf can be replaced with string concatenation (perfsprint)
        return fmt.Sprintf("Error: No such image: %s", n.imageID)
               ^
    cli/command/image/build/context.go:229:102: fmt.Sprintf can be replaced with string concatenation (perfsprint)
        progReader := progress.NewProgressReader(response.Body, progressOutput, response.ContentLength, "", fmt.Sprintf("Downloading build context from remote url: %s", remoteURL))
                                                                                                            ^
    cli/command/service/logs.go:215:16: fmt.Sprintf can be replaced with string concatenation (perfsprint)
                taskName += fmt.Sprintf(".%s", task.ID)
                            ^
    cli/command/service/logs.go:217:16: fmt.Sprintf can be replaced with string concatenation (perfsprint)
                taskName += fmt.Sprintf(".%s", stringid.TruncateID(task.ID))
                            ^
    cli/command/service/progress/progress_test.go:877:18: fmt.Sprintf can be replaced with string concatenation (perfsprint)
                ID:           fmt.Sprintf("task%s", nodeID),
                              ^
    cli/command/stack/swarm/remove.go:61:24: fmt.Sprintf can be replaced with string concatenation (perfsprint)
                errs = append(errs, fmt.Sprintf("Failed to remove some resources from stack: %s", namespace))
                                    ^
    cli/command/swarm/ipnet_slice_test.go:32:9: fmt.Sprintf can be replaced with string concatenation (perfsprint)
        arg := fmt.Sprintf("--cidrs=%s", strings.Join(vals, ","))
               ^
    cli/command/swarm/ipnet_slice_test.go:137:30: fmt.Sprintf can be replaced with string concatenation (perfsprint)
            if err := f.Parse([]string{fmt.Sprintf("--cidrs=%s", strings.Join(test.FlagArg, ","))}); err != nil {
                                       ^
    cli/compose/schema/schema.go:105:11: fmt.Sprintf can be replaced with string concatenation (perfsprint)
                return fmt.Sprintf("must be a %s", humanReadableType(expectedType))
                       ^
    cli/manifest/store/store.go:165:9: fmt.Sprintf can be replaced with string concatenation (perfsprint)
        return fmt.Sprintf("No such manifest: %s", n.object)
               ^
    e2e/image/push_test.go:340:4: fmt.Sprintf can be replaced with string concatenation (perfsprint)
                fmt.Sprintf("NOTARY_ROOT_PASSPHRASE=%s", pwd),
                ^
    e2e/image/push_test.go:341:4: fmt.Sprintf can be replaced with string concatenation (perfsprint)
                fmt.Sprintf("NOTARY_TARGETS_PASSPHRASE=%s", pwd),
                ^
    e2e/image/push_test.go:342:4: fmt.Sprintf can be replaced with string concatenation (perfsprint)
                fmt.Sprintf("NOTARY_SNAPSHOT_PASSPHRASE=%s", pwd),
                ^
    e2e/image/push_test.go:343:4: fmt.Sprintf can be replaced with string concatenation (perfsprint)
                fmt.Sprintf("NOTARY_DELEGATION_PASSPHRASE=%s", pwd),
                ^
    e2e/plugin/trust_test.go:23:16: fmt.Sprintf can be replaced with string concatenation (perfsprint)
        pluginName := fmt.Sprintf("%s/plugin-content-trust", registryPrefix)
                      ^
    e2e/plugin/trust_test.go:53:8: fmt.Sprintf can be replaced with string concatenation (perfsprint)
            Out: fmt.Sprintf("Installed plugin %s", pluginName),
                 ^
    e2e/trust/revoke_test.go:62:57: fmt.Sprintf can be replaced with string concatenation (perfsprint)
        icmd.RunCommand("docker", "tag", fixtures.AlpineImage, fmt.Sprintf("%s:v1", revokeRepo)).Assert(t, icmd.Success)
                                                               ^
    e2e/trust/revoke_test.go:64:49: fmt.Sprintf can be replaced with string concatenation (perfsprint)
            icmd.Command("docker", "-D", "trust", "sign", fmt.Sprintf("%s:v1", revokeRepo)),
                                                          ^
    e2e/trust/revoke_test.go:68:58: fmt.Sprintf can be replaced with string concatenation (perfsprint)
        icmd.RunCommand("docker", "tag", fixtures.BusyboxImage, fmt.Sprintf("%s:v2", revokeRepo)).Assert(t, icmd.Success)
                                                                ^
    e2e/trust/revoke_test.go:70:49: fmt.Sprintf can be replaced with string concatenation (perfsprint)
            icmd.Command("docker", "-D", "trust", "sign", fmt.Sprintf("%s:v2", revokeRepo)),
                                                          ^
    e2e/trust/sign_test.go:36:47: fmt.Sprintf can be replaced with string concatenation (perfsprint)
        assert.Check(t, is.Contains(result.Stdout(), fmt.Sprintf("v1: digest: sha256:%s", fixtures.AlpineSha)))
                                                     ^
    e2e/trust/sign_test.go:53:47: fmt.Sprintf can be replaced with string concatenation (perfsprint)
        assert.Check(t, is.Contains(result.Stdout(), fmt.Sprintf("v1: digest: sha256:%s", fixtures.BusyboxSha)))
                                                     ^
    e2e/trust/sign_test.go:65:47: fmt.Sprintf can be replaced with string concatenation (perfsprint)
        assert.Check(t, is.Contains(result.Stdout(), fmt.Sprintf("v1: digest: sha256:%s", fixtures.AlpineSha)))
                                                     ^
    opts/file.go:21:9: fmt.Sprintf can be replaced with string concatenation (perfsprint)
        return fmt.Sprintf("poorly formatted environment: %s", e.msg)
               ^
    opts/hosts_test.go:26:31: fmt.Sprintf can be replaced with string concatenation (perfsprint)
            "tcp://host:":              fmt.Sprintf("tcp://host:%s", defaultHTTPPort),
                                        ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 0ba14fde41)
Signed-off-by: Cory Snider <csnider@mirantis.com>
2024-09-03 19:35:23 -04:00
Sebastiaan van Stijn abf372a871 cli/command: TestGetDefaultAuthConfig: remove unused expectedErr
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 7db922cf9f)
Signed-off-by: Cory Snider <csnider@mirantis.com>
2024-09-03 19:35:23 -04:00
Sebastiaan van Stijn 416c061000 linting: fmt.Errorf can be replaced with errors.New (perfsprint)
internal/test/cli.go:175:14: fmt.Errorf can be replaced with errors.New (perfsprint)
        return nil, fmt.Errorf("no notary client available unless defined")
                    ^
    cli/command/cli.go:318:29: fmt.Errorf can be replaced with errors.New (perfsprint)
            return docker.Endpoint{}, fmt.Errorf("no context store initialized")
                                      ^
    cli/command/container/attach.go:161:11: fmt.Errorf can be replaced with errors.New (perfsprint)
                return fmt.Errorf(result.Error.Message)
                       ^
    cli/command/container/opts.go:577:16: fmt.Errorf can be replaced with errors.New (perfsprint)
                return nil, fmt.Errorf("--health-start-period cannot be negative")
                            ^
    cli/command/container/opts.go:580:16: fmt.Errorf can be replaced with errors.New (perfsprint)
                return nil, fmt.Errorf("--health-start-interval cannot be negative")
                            ^
    cli/command/container/stats.go:221:11: fmt.Errorf can be replaced with errors.New (perfsprint)
                return fmt.Errorf("filtering is not supported when specifying a list of containers")
                       ^
    cli/command/container/attach_test.go:82:17: fmt.Errorf can be replaced with errors.New (perfsprint)
            expectedErr = fmt.Errorf("unexpected error")
                          ^
    cli/command/container/create_test.go:234:40: fmt.Errorf can be replaced with errors.New (perfsprint)
                    return container.CreateResponse{}, fmt.Errorf("shouldn't try to pull image")
                                                       ^
    cli/command/container/list_test.go:150:17: fmt.Errorf can be replaced with errors.New (perfsprint)
                    return nil, fmt.Errorf("error listing containers")
                                ^
    cli/command/container/rm_test.go:40:31: fmt.Errorf can be replaced with errors.New (perfsprint)
                            return errdefs.NotFound(fmt.Errorf("Error: no such container: " + container))
                                                    ^
    cli/command/container/run_test.go:138:40: fmt.Errorf can be replaced with errors.New (perfsprint)
                    return container.CreateResponse{}, fmt.Errorf("shouldn't try to pull image")
                                                       ^
    cli/command/image/pull_test.go:115:49: fmt.Errorf can be replaced with errors.New (perfsprint)
                    return io.NopCloser(strings.NewReader("")), fmt.Errorf("shouldn't try to pull image")
                                                                ^
    cli/command/network/connect.go:88:16: fmt.Errorf can be replaced with errors.New (perfsprint)
                return nil, fmt.Errorf("invalid key/value pair format in driver options")
                            ^
    cli/command/plugin/create_test.go:96:11: fmt.Errorf can be replaced with errors.New (perfsprint)
                return fmt.Errorf("Error creating plugin")
                       ^
    cli/command/plugin/disable_test.go:32:12: fmt.Errorf can be replaced with errors.New (perfsprint)
                    return fmt.Errorf("Error disabling plugin")
                           ^
    cli/command/plugin/enable_test.go:32:12: fmt.Errorf can be replaced with errors.New (perfsprint)
                    return fmt.Errorf("failed to enable plugin")
                           ^
    cli/command/plugin/inspect_test.go:55:22: fmt.Errorf can be replaced with errors.New (perfsprint)
                    return nil, nil, fmt.Errorf("error inspecting plugin")
                                     ^
    cli/command/plugin/install_test.go:43:17: fmt.Errorf can be replaced with errors.New (perfsprint)
                    return nil, fmt.Errorf("Error installing plugin")
                                ^
    cli/command/plugin/install_test.go:51:17: fmt.Errorf can be replaced with errors.New (perfsprint)
                    return nil, fmt.Errorf("(image) when fetching")
                                ^
    cli/command/plugin/install_test.go:95:17: fmt.Errorf can be replaced with errors.New (perfsprint)
                    return nil, fmt.Errorf("should not try to install plugin")
                                ^
    cli/command/plugin/list_test.go:35:41: fmt.Errorf can be replaced with errors.New (perfsprint)
                    return types.PluginsListResponse{}, fmt.Errorf("error listing plugins")
                                                        ^
    cli/command/plugin/remove_test.go:27:12: fmt.Errorf can be replaced with errors.New (perfsprint)
                    return fmt.Errorf("Error removing plugin")
                           ^
    cli/command/registry/login_test.go:36:46: fmt.Errorf can be replaced with errors.New (perfsprint)
            return registrytypes.AuthenticateOKBody{}, fmt.Errorf("Invalid Username or Password")
                                                       ^
    cli/command/registry/login_test.go:44:46: fmt.Errorf can be replaced with errors.New (perfsprint)
            return registrytypes.AuthenticateOKBody{}, fmt.Errorf(errUnknownUser)
                                                       ^
    cli/command/system/info.go:190:10: fmt.Errorf can be replaced with errors.New (perfsprint)
            return fmt.Errorf("errors pretty printing info")
                   ^
    cli/command/system/prune.go:77:10: fmt.Errorf can be replaced with errors.New (perfsprint)
            return fmt.Errorf(`ERROR: The "until" filter is not supported with "--volumes"`)
                   ^
    cli/command/system/version_test.go:19:28: fmt.Errorf can be replaced with errors.New (perfsprint)
                return types.Version{}, fmt.Errorf("no server")
                                        ^
    cli/command/trust/key_load.go:112:22: fmt.Errorf can be replaced with errors.New (perfsprint)
                    return []byte{}, fmt.Errorf("could not decrypt key")
                                     ^
    cli/command/trust/revoke.go:44:10: fmt.Errorf can be replaced with errors.New (perfsprint)
            return fmt.Errorf("cannot use a digest reference for IMAGE:TAG")
                   ^
    cli/command/trust/revoke.go:105:10: fmt.Errorf can be replaced with errors.New (perfsprint)
            return fmt.Errorf("no signed tags to remove")
                   ^
    cli/command/trust/signer_add.go:56:10: fmt.Errorf can be replaced with errors.New (perfsprint)
            return fmt.Errorf("releases is a reserved keyword, please use a different signer name")
                   ^
    cli/command/trust/signer_add.go:60:10: fmt.Errorf can be replaced with errors.New (perfsprint)
            return fmt.Errorf("path to a public key must be provided using the `--key` flag")
                   ^
    opts/config.go:71:10: fmt.Errorf can be replaced with errors.New (perfsprint)
            return fmt.Errorf("source is required")
                   ^
    opts/mount.go:168:10: fmt.Errorf can be replaced with errors.New (perfsprint)
            return fmt.Errorf("type is required")
                   ^
    opts/mount.go:172:10: fmt.Errorf can be replaced with errors.New (perfsprint)
            return fmt.Errorf("target is required")
                   ^
    opts/network.go:90:11: fmt.Errorf can be replaced with errors.New (perfsprint)
                return fmt.Errorf("network name/id is not specified")
                       ^
    opts/network.go:129:18: fmt.Errorf can be replaced with errors.New (perfsprint)
            return "", "", fmt.Errorf("invalid key value pair format in driver options")
                           ^
    opts/opts.go:404:13: fmt.Errorf can be replaced with errors.New (perfsprint)
            return 0, fmt.Errorf("value is too precise")
                      ^
    opts/opts.go:412:18: fmt.Errorf can be replaced with errors.New (perfsprint)
            return "", "", fmt.Errorf("empty string specified for links")
                           ^
    opts/parse.go:84:37: fmt.Errorf can be replaced with errors.New (perfsprint)
            return container.RestartPolicy{}, fmt.Errorf("invalid restart policy format: no policy provided before colon")
                                              ^
    opts/parse.go:89:38: fmt.Errorf can be replaced with errors.New (perfsprint)
                return container.RestartPolicy{}, fmt.Errorf("invalid restart policy format: maximum retry count must be an integer")
                                                  ^
    opts/port.go:105:13: fmt.Errorf can be replaced with errors.New (perfsprint)
                        return fmt.Errorf("hostip is not supported")
                               ^
    opts/secret.go:70:10: fmt.Errorf can be replaced with errors.New (perfsprint)
            return fmt.Errorf("source is required")
                   ^
    opts/env_test.go:57:11: fmt.Errorf can be replaced with errors.New (perfsprint)
                err:   fmt.Errorf("invalid environment variable: =a"),
                       ^
    opts/env_test.go:93:11: fmt.Errorf can be replaced with errors.New (perfsprint)
                err:   fmt.Errorf("invalid environment variable: ="),
                       ^
    cli-plugins/manager/error_test.go:16:11: fmt.Errorf can be replaced with errors.New (perfsprint)
        inner := fmt.Errorf("testing")
                 ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit dfec976e84)
Signed-off-by: Cory Snider <csnider@mirantis.com>
2024-09-03 19:35:23 -04:00
Sebastiaan van Stijn 5adf6be6d8 cli/command/network: fix linting issue and pass client instead of cli
Rename variable that shadowed an import, and pass the network API-client
instead of the whole CLI

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit e93abde7a0)
Signed-off-by: Cory Snider <csnider@mirantis.com>
2024-09-03 19:35:23 -04:00
Sebastiaan van Stijn fcad2c6584 image/build: use "nolint" comment to work around gosec regression
Latest gosec linter has a regression in parsing "nosec" comments;
see https://github.com/securego/gosec/issues/1046

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 9e1f8d646e)
Signed-off-by: Cory Snider <csnider@mirantis.com>
2024-09-03 19:35:23 -04:00
Sebastiaan van Stijn 3e271deeca cli/command: remove dot-imports and unhandled errors
Please the linters in preparation of updating golangci-lint;

- remove dot-imports
- add some checks for unhandled errors
- replace some fixed-value variables for consts

    cli/command/image/build/context.go:238:17: G107: Potential HTTP request made with variable url (gosec)
        if resp, err = http.Get(url); err != nil {
                       ^
    cli/command/idresolver/idresolver_test.go:7:2: dot-imports: should not use dot imports (revive)
        . "github.com/docker/cli/internal/test/builders" // Import builders to get the builder function as package function
        ^
    cli/command/registry_test.go:7:2: dot-imports: should not use dot imports (revive)
        . "github.com/docker/cli/cli/command" // Prevents a circular import with "github.com/docker/cli/internal/test"
        ^
    cli/command/task/print_test.go:11:2: dot-imports: should not use dot imports (revive)
        . "github.com/docker/cli/internal/test/builders" // Import builders to get the builder function as package function
        ^
    cli/command/swarm/update_test.go:10:2: dot-imports: should not use dot imports (revive)
        . "github.com/docker/cli/internal/test/builders" // Import builders to get the builder function as package function
        ^
    cli/command/swarm/unlock_key_test.go:9:2: dot-imports: should not use dot imports (revive)
        . "github.com/docker/cli/internal/test/builders" // Import builders to get the builder function as package function
        ^
    cli/command/swarm/join_token_test.go:9:2: dot-imports: should not use dot imports (revive)
        . "github.com/docker/cli/internal/test/builders" // Import builders to get the builder function as package function
        ^
    cli/command/node/list_test.go:9:2: dot-imports: should not use dot imports (revive)
        . "github.com/docker/cli/internal/test/builders" // Import builders to get the builder function as package function
        ^
    cli/command/node/promote_test.go:8:2: dot-imports: should not use dot imports (revive)
        . "github.com/docker/cli/internal/test/builders" // Import builders to get the builder function as package function
        ^
    cli/command/node/demote_test.go:8:2: dot-imports: should not use dot imports (revive)
        . "github.com/docker/cli/internal/test/builders" // Import builders to get the builder function as package functions
        ^
    cli/command/node/ps_test.go:11:2: dot-imports: should not use dot imports (revive)
        . "github.com/docker/cli/internal/test/builders" // Import builders to get the builder function as package function
        ^
    cli/command/node/update_test.go:8:2: dot-imports: should not use dot imports (revive)
        . "github.com/docker/cli/internal/test/builders" // Import builders to get the builder function as package function
        ^
    cli/command/node/inspect_test.go:9:2: dot-imports: should not use dot imports (revive)
        . "github.com/docker/cli/internal/test/builders" // Import builders to get the builder function as package functions
        ^
    cli/command/secret/ls_test.go:11:2: dot-imports: should not use dot imports (revive)
        . "github.com/docker/cli/internal/test/builders" // Import builders to get the builder function as package function
        ^
    cli/command/secret/inspect_test.go:11:2: dot-imports: should not use dot imports (revive)
        . "github.com/docker/cli/internal/test/builders" // Import builders to get the builder function as package function
        ^
    cli/command/volume/inspect_test.go:9:2: dot-imports: should not use dot imports (revive)
        . "github.com/docker/cli/internal/test/builders" // Import builders to get the builder function as package function
        ^
    cli/command/volume/list_test.go:9:2: dot-imports: should not use dot imports (revive)
        . "github.com/docker/cli/internal/test/builders" // Import builders to get the builder function as package function
        ^
    cli/command/config/inspect_test.go:11:2: dot-imports: should not use dot imports (revive)
        . "github.com/docker/cli/internal/test/builders" // Import builders to get the builder function as package function
        ^
    cli/command/config/ls_test.go:11:2: dot-imports: should not use dot imports (revive)
        . "github.com/docker/cli/internal/test/builders" // Import builders to get the builder function as package function
        ^
    cli/command/network/list_test.go:9:2: dot-imports: should not use dot imports (revive)
        . "github.com/docker/cli/internal/test/builders"
        ^
    cli/command/container/list_test.go:10:2: dot-imports: should not use dot imports (revive)
        . "github.com/docker/cli/internal/test/builders" // Import builders to get the builder function as package function
        ^
    cli/command/service/list_test.go:12:2: dot-imports: should not use dot imports (revive)
        . "github.com/docker/cli/internal/test/builders"
        ^
    cli/command/service/client_test.go:6:2: dot-imports: should not use dot imports (revive)
        . "github.com/docker/cli/internal/test/builders" // Import builders to get the builder function as package function
        ^
    cli/command/stack/list_test.go:8:2: dot-imports: should not use dot imports (revive)
        . "github.com/docker/cli/internal/test/builders" // Import builders to get the builder function as package function
        ^
    cli/command/stack/services_test.go:9:2: dot-imports: should not use dot imports (revive)
        . "github.com/docker/cli/internal/test/builders" // Import builders to get the builder function as package function
        ^
    cli/command/stack/ps_test.go:10:2: dot-imports: should not use dot imports (revive)
        . "github.com/docker/cli/internal/test/builders" // Import builders to get the builder function as package function
        ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 594aeb390a)
Signed-off-by: Cory Snider <csnider@mirantis.com>
2024-09-03 19:35:23 -04:00
Sebastiaan van Stijn 867baaff66 swarm: TestSwarmUpdate: remove non-existing "--quiet" flag
The `docker swarm update` copmmand does not have a `--quiet` flag, but this
test was trying to set it.

    docker swarm update --help

    Usage:  docker swarm update [OPTIONS]

    Update the swarm

    Options:
          --autolock                        Change manager autolocking setting (true|false)
          --cert-expiry duration            Validity period for node certificates (ns|us|ms|s|m|h) (default 2160h0m0s)
          --dispatcher-heartbeat duration   Dispatcher heartbeat period (ns|us|ms|s|m|h) (default 5s)
          --external-ca external-ca         Specifications of one or more certificate signing endpoints
          --max-snapshots uint              Number of additional Raft snapshots to retain
          --snapshot-interval uint          Number of log entries between Raft snapshots (default 10000)
          --task-history-limit int          Task history retention limit (default 5)

The test didn't catch this issue, because errors when setting the flag were
not handled, so also adding error-handling;

    === Failed
    === FAIL: cli/command/swarm TestSwarmUpdate (0.00s)
        update_test.go:177: assertion failed: error is not nil: no such flag -quiet

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit b08e34b9f9)
Signed-off-by: Cory Snider <csnider@mirantis.com>
2024-09-03 19:35:23 -04:00
Sebastiaan van Stijn 58e6338654 cli/registry: client.iterateEndpoints: remove check for APIVersion1
registryService.LookupPullEndpoints uses lookupV2Endpoints
https://github.com/moby/moby/blob/v24.0.5/registry/service.go#L137-L142

which, as the name indicates, only returns V2 endpoints;
https://github.com/moby/moby/blob/v24.0.5/registry/service_v2.go#L10-L80

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 22b4bab90f)
Signed-off-by: Cory Snider <csnider@mirantis.com>
2024-09-03 19:35:23 -04:00
Sebastiaan van Stijn f18b630f22 cli/registry: fix client.pullManifestList not de-referencing manifest
Kudos to gosec;

    cli/registry/client/fetcher.go:205:57: G601: Implicit memory aliasing in for loop. (gosec)
            imageManifest.Descriptor.Platform = types.OCIPlatform(&manifestDescriptor.Platform)
                                                                  ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 5250f1bab5)
Signed-off-by: Cory Snider <csnider@mirantis.com>
2024-09-03 19:35:23 -04:00
Sebastiaan van Stijn 77a921c5c8 update golangci-lint to v1.54.2
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit db6209abdd)
Signed-off-by: Austin Vazquez <macedonv@amazon.com>
2024-09-03 19:35:23 -04:00
Eric Bode ddaded1b1c
Fix setting ServerAddress property in NativeStore
This will return the ServerAddress property when using the NativeStore.
This happens when you use docker credential helpers, not the credential
store.

The reason this fix is needed is because it needs to be propagated
properly down towards `moby/moby` project in the following logic:

```golang
func authorizationCredsFromAuthConfig(authConfig registrytypes.AuthConfig) docker.AuthorizerOpt {
	cfgHost := registry.ConvertToHostname(authConfig.ServerAddress)
	if cfgHost == "" || cfgHost == registry.IndexHostname {
		cfgHost = registry.DefaultRegistryHost
	}

	return docker.WithAuthCreds(func(host string) (string, string, error) {
		if cfgHost != host {
			logrus.WithFields(logrus.Fields{
				"host":    host,
				"cfgHost": cfgHost,
			}).Warn("Host doesn't match")
			return "", "", nil
		}
		if authConfig.IdentityToken != "" {
			return "", authConfig.IdentityToken, nil
		}
		return authConfig.Username, authConfig.Password, nil
	})
}
```
This logic resides in the following file :
`daemon/containerd/resolver.go` .

In the case when using the containerd storage feature when setting the
`cfgHost` variable from the `authConfig.ServerAddress` it will always be
empty. Since it will never be returned from the NativeStore currently.
Therefore Docker Hub images will work fine, but anything else will fail
since the `cfgHost` will always be the `registry.DefaultRegistryHost`.

Signed-off-by: Eric Bode <eric.bode@foundries.io>
(cherry picked from commit b24e7f85a4)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-01-24 15:45:23 +01:00
Sebastiaan van Stijn e26416f371
cli/registry/client: set actions when authn with token
When using a personal access token, Docker Hub produces an error if actions
are requested beyond the token's allowed actions. This resulted in errors
when using a PAT with limited permissions to do a "docker manifest inspect".

This patch sets actions to "pull" only by default, and requests "push" action
for requests that need it.

To verify:

- create a PAT with limited access (read-only)
- log in with your username and the PAT as password

Before this patch:

    docker manifest inspect ubuntu:latest
    Get "https://registry-1.docker.io/v2/library/ubuntu/manifests/latest": unauthorized: access token has insufficient scopes

With this patch applied:

    docker manifest inspect ubuntu:latest
    {
       "schemaVersion": 2,
       "mediaType": "application/vnd.oci.image.index.v1+json",
       "manifests": [
          {
             "mediaType": "application/vnd.oci.image.manifest.v1+json",
             "size": 424,
             "digest": "sha256:56887c5194fddd8db7e36ced1c16b3569d89f74c801dc8a5adbf48236fb34564",
             "platform": {
                "architecture": "amd64",
                "os": "linux"
             }
          },
          {
             "mediaType": "application/vnd.oci.image.manifest.v1+json",
             "size": 424,
             "digest": "sha256:c835a4f2a632bc91a2b494e871549f0dd83f2966c780e66435774e77e048ddf0",
             "platform": {
                "architecture": "arm",
                "os": "linux",
                "variant": "v7"
             }
          }
       ]
    }

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit d2047b954e)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-22 21:56:45 +02:00
Danial b0dca399b1 configfile: Initialize nil AuthConfigs
Initialize AuthConfigs map if it's nil before returning it.
This fixes fileStore.Store nil dereference panic when adding a new key
to the map.

Signed-off-by: Danial Gharib <danial.mail.gh@gmail.com>
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
(cherry picked from commit ad43df5e86)
2023-07-19 16:18:16 +02:00
Sebastiaan van Stijn 0d34fe7fb2
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 <github@gone.nl>
(cherry picked from commit 90380d9576)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-15 15:25:23 +02:00
Sebastiaan van Stijn 3b389dd273
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 <github@gone.nl>
(cherry picked from commit dd6ede2109)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-15 15:25:13 +02:00
Sebastiaan van Stijn 28f1b586f6
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 <github@gone.nl>
(cherry picked from commit 7c8680c69b)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-15 15:25:05 +02:00
Sebastiaan van Stijn dcec47bf2b
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 <github@gone.nl>
(cherry picked from commit 6355bcee66)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-15 15:24:55 +02:00
Sebastiaan van Stijn b298f8f2cd
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 <github@gone.nl>
(cherry picked from commit 607f290f65)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-15 15:24:46 +02:00
Sebastiaan van Stijn 8cbad756d9
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 <github@gone.nl>
(cherry picked from commit 546cf6d985)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-15 15:24:36 +02:00
Sebastiaan van Stijn 93772a590d
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 <github@gone.nl>
(cherry picked from commit b32b28041d)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-15 15:24:26 +02:00
Sebastiaan van Stijn fec554c357
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 <github@gone.nl>
(cherry picked from commit 40a51d5543)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-15 15:24:17 +02:00
Sebastiaan van Stijn be6f8b2b69
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 <github@gone.nl>
(cherry picked from commit b0d0b0efcb)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-15 15:24:07 +02:00
Sebastiaan van Stijn 67474fb865
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 <github@gone.nl>
(cherry picked from commit c69640d8c1)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-15 15:23:56 +02:00
Sebastiaan van Stijn 5840a39af4
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 <github@gone.nl>
(cherry picked from commit 5254081fd6)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-15 15:23:45 +02:00
Sebastiaan van Stijn e2949a1333
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 <github@gone.nl>
(cherry picked from commit da3416c023)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-15 15:23:34 +02:00
Sebastiaan van Stijn e7f258feaf
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 <github@gone.nl>
(cherry picked from commit 625988c3aa)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-15 15:23:22 +02:00
Sebastiaan van Stijn 9835110f8b
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 <github@gone.nl>
(cherry picked from commit 92d9e3bf69)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-15 15:23:09 +02:00
Sebastiaan van Stijn cb6a1dfe6f
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 <github@gone.nl>
(cherry picked from commit 316c4992c4)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-15 15:23:00 +02:00
Sebastiaan van Stijn 3eee043fec
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 <github@gone.nl>
(cherry picked from commit ae5a86bb8d)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-15 15:22:51 +02:00
Sebastiaan van Stijn d07bce7fd2
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 <github@gone.nl>
(cherry picked from commit 38ef40ee7a)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-15 15:22:31 +02:00
Sebastiaan van Stijn 63e163cf3c
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 <github@gone.nl>
(cherry picked from commit 45b5676acd)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-15 15:22:21 +02:00
Sebastiaan van Stijn 42e07e50fb
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 <github@gone.nl>
(cherry picked from commit 5563c5a91d)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-15 15:22:12 +02:00
Sebastiaan van Stijn 6ef0757c0e
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 <github@gone.nl>
(cherry picked from commit 9dd012aa5d)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-15 15:21:58 +02:00
Sebastiaan van Stijn d741c64884
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 <github@gone.nl>
(cherry picked from commit 66c66bdce7)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-15 15:21:48 +02:00
Sebastiaan van Stijn c0581e8a38
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 <github@gone.nl>
(cherry picked from commit a2d532819d)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-15 15:21:26 +02:00
Sebastiaan van Stijn ae7cd7e16a
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 <github@gone.nl>
(cherry picked from commit 9252fae838)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-15 15:21:09 +02:00
Sebastiaan van Stijn 9e8d522f77
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 <github@gone.nl>
(cherry picked from commit 92506afd49)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-15 15:21:00 +02:00
Sebastiaan van Stijn 3882e674e4
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;
88924b1802/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 <github@gone.nl>
(cherry picked from commit c3d7f167bd)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-15 15:20:50 +02:00
Sebastiaan van Stijn 10483a1bfe
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 <github@gone.nl>
(cherry picked from commit b4aff3a14d)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-15 15:20:41 +02:00
Sebastiaan van Stijn de94fd5ecf
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 <github@gone.nl>
(cherry picked from commit f08252c10a)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-15 15:20:30 +02:00
Sebastiaan van Stijn 9cc20a29ce
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 <github@gone.nl>
(cherry picked from commit 78c474539b)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-15 15:20:17 +02:00
Sebastiaan van Stijn c092f42b29
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 <github@gone.nl>
(cherry picked from commit be97731f1a)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-07-15 15:20:07 +02:00
David Karlsson c76773b197 docs: update description for docker -H flag
Signed-off-by: David Karlsson <david.karlsson@docker.com>
(cherry picked from commit 759fa585cf)
Signed-off-by: David Karlsson <david.karlsson@docker.com>
2023-05-08 15:11:10 +02:00
Sebastiaan van Stijn 776388cc19
Merge pull request #4229 from thaJeztah/23.0_backport_volumes_prune_all
[23.0 backport] volumes: prune: add --all / -a option
2023-04-26 13:00:58 +02:00
Sebastiaan van Stijn f914316a97
fix docker version --format=json not outputting json format
The --format=json option was added for all inspect commands, but was not
implemented for "docker version". This patch implements the missing option.

Before this patch:

    docker version --format=json
    json

With this patch:

    docker version --format=json
    {"Client":{"Platform":{"Name":""},"Version":"24.0.0-dev","ApiVersion":"..."}}

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 23bd746c43)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-04-26 12:12:25 +02:00
Sebastiaan van Stijn 9dfe5a29ee
cli/command/system: make default version template a const
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 80640bca72)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-04-26 12:12:25 +02:00
Sebastiaan van Stijn 2c1fde2239
fix docker info --format=json not outputting json format
The --format=json option was added for all inspect commands, but was not implemented
for "docker info". This patch implements the missing option.

Before this patch:

    docker info --format=json
    json

With this patch applied:

    docker info --format=json
    {"ID":"80c2f18a-2c88-4e4a-ba69-dca0eea59835","Containers":7,"ContainersRunning":"..."}

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 46234b82e2)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-04-26 12:12:25 +02:00
Sebastiaan van Stijn 99124087e0
cli/command/formatter: export JSONFormat const
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 1aaa179d9d)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-04-26 12:12:24 +02:00