1
0
mirror of https://github.com/docker/cli.git synced 2026-01-26 15:41:42 +03:00
Commit Graph

12190 Commits

Author SHA1 Message Date
Sebastiaan van Stijn
b8cda96d11 cli/command/container: improve TestContainerStatsContext
- Don't use unnamed keys
- Use sub-tests
- Add test-cases for Name and ID fields

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-11 13:58:50 +02:00
Sebastiaan van Stijn
82281087e3 Merge pull request #6448 from thaJeztah/cleanup_completion
cli/command/completion: change signatures to return a cobra.CompletionFunc
2025-09-10 15:08:18 +02:00
Sebastiaan van Stijn
c3ceba2548 Merge pull request #6447 from thaJeztah/default_completion
cli: disable file-completion by default
2025-09-10 15:07:03 +02:00
Sebastiaan van Stijn
e78f16961d Merge pull request #6449 from thaJeztah/context_name_positional
cli/command/context: split name from options struct
2025-09-10 15:05:43 +02:00
Sebastiaan van Stijn
d391d0fa4a Merge pull request #6445 from thaJeztah/add_plugin_completions
cli/command/plugin: add completion for plugin subcommands
2025-09-10 15:04:43 +02:00
Sebastiaan van Stijn
2f6abcf3c2 Merge pull request #6446 from thaJeztah/fix_completions
Improve shell completion for `docker secret` and `docker config` subcommands
2025-09-10 14:30:05 +02:00
Sebastiaan van Stijn
ea8212ab55 cli/command/context: split name from options struct
Name is a required argument for both "create" and "update", so better
to split it from the options struct.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-10 12:15:50 +02:00
Sebastiaan van Stijn
3785198c6e cli/command/completion: change FileNames to return a cobra.CompletionFunc
It's adding a slight indirection by constructing a function when called,
but makes the completion functions more consistent, the signature easier
to read, and making the return type a [cobra.CompletionFunc] makes it
more transparent what it's intended for, and helps discovery of functions
that provide completion.

[cobra.CompletionFunc]: https://pkg.go.dev/github.com/spf13/cobra#CompletionFunc

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-10 12:06:43 +02:00
Sebastiaan van Stijn
531f7e121d cli/command/completion: change Platforms to return a cobra.CompletionFunc
It's adding a slight indirection by constructing a function when called,
but makes the completion functions more consistent, the signature easier
to read, and making the return type a [cobra.CompletionFunc] makes it
more transparent what it's intended for, and helps discovery of functions
that provide completion.

[cobra.CompletionFunc]: https://pkg.go.dev/github.com/spf13/cobra#CompletionFunc

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-10 12:06:42 +02:00
Sebastiaan van Stijn
810be9fbe9 cli/command/completion: change Platforms to return a cobra.CompletionFunc
It's adding a slight indirection by constructing a function when called,
but makes the completion functions more consistent, the signature easier
to read, and making the return type a [cobra.CompletionFunc] makes it
more transparent what it's intended for, and helps discovery of functions
that provide completion.

[cobra.CompletionFunc]: https://pkg.go.dev/github.com/spf13/cobra#CompletionFunc

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-10 12:06:42 +02:00
Sebastiaan van Stijn
d18af47d0f cli/command/completion: change EnvVarNames to return a cobra.CompletionFunc
It's adding a slight indirection by constructing a function when called,
but makes the completion functions more consistent, the signature easier
to read, and making the return type a [cobra.CompletionFunc] makes it
more transparent what it's intended for, and helps discovery of functions
that provide completion.

[cobra.CompletionFunc]: https://pkg.go.dev/github.com/spf13/cobra#CompletionFunc

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-10 12:06:39 +02:00
Sebastiaan van Stijn
47b1715d6f cli-plugins: disable file-completion by default
This uses the DefaultShellCompDirective feature which was added
in cobra to override the default (which would complete to use
files for commands and flags).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-10 11:52:32 +02:00
Sebastiaan van Stijn
78c54646c3 cli: disable file-completion by default
This uses the DefaultShellCompDirective feature which was added
in cobra to override the default (which would complete to use
files for commands and flags).

Note that we set "cobra.NoFileCompletions" for many commands, which
is redundant with this change, so we could remove as well.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-10 11:52:32 +02:00
Sebastiaan van Stijn
467fcfe4bd cli/command/plugin: add completion for plugin subcommands
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-10 11:49:16 +02:00
Sebastiaan van Stijn
8325214ccc cli/command: fix completion for secret create, config create
These commands accept two arguments; the first is a custom name,
the second is either a filename or "-" to create from STDIN.

With this patch:

    # does not provide completion
    docker secret create <tab>

    # starts providing completion once a non-empty name is provided
    docker secret create somename<tab>
    file.txt other-file.txt

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-10 11:45:21 +02:00
Sebastiaan van Stijn
924dd4710b cli/command/secret: fix completion to complete names, not IDs
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-10 11:45:21 +02:00
Sebastiaan van Stijn
d67dad3fb4 cli/command/secret: remove completion for "ls"
This command takes no arguments, so should not provide completion.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-10 11:40:42 +02:00
Sebastiaan van Stijn
1336f51e6a remove redundant closures around completion functions
These were remnants from some earlier implementation.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-10 11:40:42 +02:00
Sebastiaan van Stijn
c5467b5556 Merge pull request #6246 from mmorel-35/revive/use-errors-new
ci: enable use-errors-new from revive
2025-09-10 11:38:14 +02:00
Sebastiaan van Stijn
8b23c2bcb5 Merge pull request #6444 from thaJeztah/inspect_completion
cli/command/system: add shell completion for "docker inspect"
2025-09-10 11:36:23 +02:00
Matthieu MOREL
22dda0fc2b ci: enable use-errors-new from revive
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-09-10 11:31:26 +02:00
Sebastiaan van Stijn
69972b682b Merge pull request #6441 from thaJeztah/stderrs
cli/command: replace remaining uses of pkg/errors for stdlib
2025-09-10 10:20:21 +02:00
Sebastiaan van Stijn
8bb5595f28 cli/command/system: add shell completion for "docker inspect"
The "docker inspect" command can inspect any type of object, which would
require all possible endpoints to be contacted. By default, we don't
provide completion, but if a `--type` is passed, we provide completion
for the given type.

For example, `docker inspect --type container` will complete container
names, `docker inspect --type volume` will complete volume names and
so on.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-10 00:28:08 +02:00
Sebastiaan van Stijn
5245e20866 update vendor
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-09 19:58:08 +02:00
Sebastiaan van Stijn
c0e37dda14 cli/command/container: use stdlib errors
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-09 19:58:08 +02:00
Sebastiaan van Stijn
b774e75931 cli/command/system: use stdlib errors
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-09 19:58:07 +02:00
Sebastiaan van Stijn
9ba1314d3a cli/command/system: fix error formatting (errlint)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-09 19:58:07 +02:00
Sebastiaan van Stijn
c5150177bf cli/command/secret: use stdlib errors
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-09 19:58:07 +02:00
Sebastiaan van Stijn
573e0bddef cli/command/service: use stdlib errors
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-09 19:58:07 +02:00
Sebastiaan van Stijn
b057ab6d98 cli/command/stack: use stdlib errors
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-09 19:58:07 +02:00
Sebastiaan van Stijn
0e4934d36c cli/command/swarm: use stdlib errors
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-09 19:58:06 +02:00
Sebastiaan van Stijn
cd583313ee cli/command/plugin: use stdlib errors
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-09 19:58:06 +02:00
Sebastiaan van Stijn
5c8817b1b2 cli/command/node: use stdlib errors
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-09 19:58:06 +02:00
Sebastiaan van Stijn
bf78331f0c cli/command/container: runUpdate: use struct-literal
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-09 19:58:06 +02:00
Sebastiaan van Stijn
0c3bb6c0a4 cli/command/container: rename: remove renameOptions
Also remove redundant validation that's already performed by the client
or daemon.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-09 19:57:42 +02:00
Sebastiaan van Stijn
179dc0228c cli/command/image: use stdlib errors
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-09 17:23:58 +02:00
Sebastiaan van Stijn
f10041c724 Merge pull request #6439 from thaJeztah/plugin_rm_special_handling
cli/command/plugin: remove special error handling on install, upgrade
2025-09-09 11:59:51 +02:00
Sebastiaan van Stijn
62d25205e9 Merge pull request #6440 from thaJeztah/use_multierror
use native errors.Join for multi-errors on "docker ps", "docker node ls"
2025-09-09 10:47:23 +02:00
Sebastiaan van Stijn
fb3f2da50e cli/command/plugin: remove special error handling on install, upgrade
Similar to 323fbc485e - this code was added
in [moby@c127d96], but used string-matching to detect cases where a user
tried to install an image as plugin. However, this handling no longer matched
any error-strings, so no longer worked:

    docker plugin install busybox
    Error response from daemon: did not find plugin config for specified reference docker.io/library/busybox:latest

[moby@c127d96]: c127d9614f

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-08 20:37:03 +02:00
Sebastiaan van Stijn
5df02441ca cli/command/containers: runUpdate: use native errors.Join
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-08 20:30:41 +02:00
Sebastiaan van Stijn
935df8a78f cli/command/node: runPs: use native errors.Join
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-08 20:30:41 +02:00
Sebastiaan van Stijn
183337db9a Merge pull request #6438 from thaJeztah/internalize_loader
cli/command/stack: internalize GetConfigDetails, LoadComposefile, RunDeploy, RunRemove
2025-09-08 17:31:28 +02:00
Sebastiaan van Stijn
d62d370c23 Merge pull request #6435 from thaJeztah/templates_extract_formatJSON
templates: add formatJSON func
2025-09-08 17:30:37 +02:00
Sebastiaan van Stijn
26bb688ed0 cli/command/stack: internalize RunDeploy, RunRemove
These were deprecated in ad6ab189a6 and
were only used internally. Move them back inside the stack package.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-08 16:03:38 +02:00
Sebastiaan van Stijn
73677146f4 cli/command/stack: internalize GetConfigDetails, LoadComposefile
These were deprecated in ad6ab189a6 and
were only used internally. Move them back inside the stack package.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-08 15:24:35 +02:00
Sebastiaan van Stijn
c24b62f19c templates: add formatJSON func
Move the function used to format as JSON to a separate function instead
of definining it inline.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-08 12:06:46 +02:00
Sebastiaan van Stijn
be97096566 Merge pull request #6434 from thaJeztah/update_authors
update mailmap and authors
2025-09-06 00:18:07 +02:00
Sebastiaan van Stijn
c4a87de3ec update mailmap and authors
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-06 00:06:56 +02:00
Paweł Gronowski
4df42ef1d9 Merge pull request #6395 from thaJeztah/bump_engine
vendor: github.com/moby/moby/api v1.52.0-beta.1, client v0.1.0-beta.0
2025-09-05 23:39:16 +02:00
Sebastiaan van Stijn
b55fed5ef6 vendor: github.com/moby/moby/api v1.52.0-beta.1, client v0.1.0-beta.0
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Co-authored-by: Austin Vazquez <austin.vazquez@docker.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-05 22:41:03 +02:00