Commit Graph

537 Commits

Author SHA1 Message Date
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
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
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
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
0adaf6be3b verify that DisableFlagsInUseLine is set for all commands
This replaces the visitAll recursive function with a test that verifies that
the option is set for all commands and subcommands, so that it doesn't have
to be modified at runtime.

We currently still have to loop over all functions for the setValidateArgs
call, but that can be looked at separately.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-01 09:39:46 +02:00
2827d037ba cli/command/completion: deprecate NoComplete
This function was an exact duplicate of [cobra.NoFileCompletions], so
deprecating it in favor of that.

[cobra.NoFileCompletions]: https://pkg.go.dev/github.com/spf13/cobra@v1.9.1#NoFileCompletions

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-08-30 12:00:34 +02:00
cdf705ce66 vendor: github.com/moby/moby/api, github.com/moby/moby/client master
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-08-27 17:12:11 +02:00
10072c3548 vendor: github.com/moby/moby/api, github.com/moby/moby/client 62884141100c
full diffs:

- 7145e7666b...6288414110

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-08-27 10:21:32 +02:00
7118f1fb4b vendor: github.com/moby/moby/api, moby/moby/client 7145e7666b8f (master)
full diff:

- https://github.com/docker/docker/compare/api/v1.52.0-alpha.1...7145e7666b8f
- https://github.com/docker/docker/compare/client/v0.1.0-alpha.0...7145e7666b8f

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

WIP latest

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-08-26 20:02:30 +02:00
9fd71c8347 cli/command: rename vars for consistency and prevent shadowing
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-08-23 03:04:36 +02:00
206a8da307 cli/command/container: remove deprecated formatting functions
These were deprecated in 907507e22a and
fdc90caeee, which are part of the v28.4
release.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-08-22 09:38:09 +02:00
873609d790 cli/command/*: remove deprecated cobra command constructors
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-08-21 11:12:28 +02:00
56cab16779 Register CLI commands implicitly
This patch removes the explicit `commands.AddCommands` function and
instead relies upon the `internal/commands` package which registers each
CLI command using `init()` instead.

Signed-off-by: Alano Terblanche <18033717+Benehiko@users.noreply.github.com>
2025-08-21 07:16:35 +02:00
38595fecb6 Unexport container commands
This patch deprecates exported container commands and moves the
implementation details to an unexported function.

Commands that are affected include:
- container.NewRunCommand
- container.NewExecCommand
- container.NewPsCommand
- container.NewContainerCommand
- container.NewAttachCommand
- container.NewCommitCommand
- container.NewCopyCommand
- container.NewCreateCommand
- container.NewDiffCommand
- container.NewExportCommand
- container.NewKillCommand
- container.NewLogsCommand
- container.NewPauseCommand
- container.NewPortCommand
- container.NewRenameCommand
- container.NewRestartCommand
- container.NewRmCommand
- container.NewStartCommand
- container.NewStatsCommand
- container.NewStopCommand
- container.NewTopCommand
- container.NewUnpauseCommand
- container.NewUpdateCommand
- container.NewWaitCommand
- container.NewPruneCommand

Signed-off-by: Alano Terblanche <18033717+Benehiko@users.noreply.github.com>
2025-08-19 11:12:19 +02:00
69854c4e08 cli/command/container: TestRunPullTermination: rewrite with streamformatter
This makes the test slightly closer to the actual code in the daemon producing
the progress response;
cd844fd0b2/daemon/images/image_pull.go (L58-L70)
cd844fd0b2/daemon/internal/distribution/utils/progress.go (L14-L34)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-08-18 15:21:14 +02:00
eb5b03a8a3 cli/command/container: copyToContainer: improve error-handling
The logic used in this function was confusing; some errors were ignored,
but responses handled regardless. The intent here is to try to detect
whether the destination exists inside the container and is of the right
"type" (otherwise produce an error).

Failing to "stat" the path in the container means we can't produce a
nice error for the user, but we'll continue the request, which either
would succeed or produce an error returned by the daemon.

While working on this patch, I noticed that some error-handling on the
daemon side is incorrect. This patch does not fix those cases, but
makes the logic slightly easier to follow (we should consider extracting
the "stat" code to a separate function though).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-08-13 00:24:31 +02:00
c5ea9079af cli/command/container: copyToContainer rename error-return
Make it more clearly identifiable where we're dealing with the
named error-return

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-08-12 18:53:12 +02:00
e069ded4c3 cli: reduce uses of pkg/errors for stdlib errors
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-08-11 19:00:02 +02:00
7026e68a71 cli/command: remove AddPlatformFlag utility
It was only used internally and has no external users. It should not be
used for new uses, because it also adds a minimum API version constraint
and a default from env-var, which must be evaluated for each individual
use of such flags.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-08-06 17:15:32 +02:00
c0fbbe05ca cli/command: remove AddTrustVerificationFlags
It was only used internally; inline it where used.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-08-06 17:00:25 +02:00
f1ceb8c55d Merge pull request #6236 from thaJeztah/system_prune_register
system prune: refactor to use "register" functions
2025-08-05 23:25:51 +02:00
f9431e3b35 vendor: moby/moby/api v1.52.0-alpha.1, moby/moby/client v0.1.0-alpha.0
full diff: 4faedf2bec...37d0204d7f

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-08-05 22:01:50 +02:00
3b6a556533 cli/command: remove exported "RunPrune" functions
These are no longer used, and unlikely to be used externally.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-08-04 00:08:03 +02:00
a888c4091c system prune: delegate confirmation message and validation
This adds a "dry-run" / "pre-check" option for prune-functions,
which delegates constructing the confirmation message (what is
about to be pruned) and validation of the given options to the
prune-functions.

This helps separating concerns, and doesn't enforce knowledge
about what's supported by each content-type onto the system
prune command.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-08-04 00:07:54 +02:00
02d578b637 system prune: use register function for prune functions
Introduce a "prune" package in which we maintain a list of prune
functions that are registered. Known prune "content-types" are
included in a pre-defined order, after which additional content
can be registered.

Using this approach no longer requires the "RunPrune" functions
to be exported, and allows additional content-types to be
introduced without having to import those packages into the
system package, so keeping things more decoupled.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-08-03 23:52:47 +02:00
f937e62c89 replace direct uses of github.com/docker/go-connections/nat types
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-07-31 17:37:34 +02:00
bf16dd1251 vendor: docker/docker, moby/moby/api and moby/moby/client 4faedf2bec36
notable changes:

- api: remove deprecated NoBaseImageSpecifier
- api/stdcopy: move to api/pkg/stdcopy
- api/types/container: add aliases for go-connections/nat types
- pkg/progress: move to api/pkg/progress
- pkg/jsonmessage: move JSONError to api/types/jsonstream
- pkg/jsonmessage: move JSONProgress to api/types/jsonstream
- pkg/jsonmessage: move to client/pkg/jsonmessage
- pkg/jsonmessage: remove github.com/morikuni/aec dependency
- pkg/jsonmessage: stop printing deprecated progressDetail, errorDetail,
  remove DisplayJSONMessagesToStream and Stream interface
- pkg/streamformatter: move to api/pkg/streamformatter
- pkg/streamformatter: split from pkg/jsonmessage

full diff: 2574c2b2e9...4faedf2bec

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-07-31 17:31:01 +02:00
89d8c8a2a7 remove aliases for containerd/errdefs, disallow docker/errdefs
We transitioned most functionality of docker/errdefs to containerd
errdefs module, and the docker/errdefs package should no longer be
used.

Because of that, there will no longer be ambiguity, so we can remove
the aliases for this package, and use it as "errdefs".

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-07-28 14:55:43 +02:00
e2a4e429bc Merge pull request #6211 from thaJeztah/bump_engine
vendor: update docker, api, client to master, consume client/pkg/stringid
2025-07-28 14:25:36 +02:00
4bd6b6897f vendor: update docker, api, client to master
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-07-28 08:50:13 +02:00
7ab3e7e774 templates: deprecate NewParse()
It it just a chain of `New("sometag").Parse(...)`, and most of our
uses don't use a tag for the template, so can call Parse.

There's no public users of this function, but deprecating it first
just in case.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-07-28 08:25:02 +02:00
ef7fd8bb67 refactor(cli/compose/loader): extract ParseVolume() to its own package
Moves ParseVolume() to a new internal package to remove the dependency
on cli/compose/loader in cli/command/container/opts.go

refactor to keep types isolated

- rename the package to "volumespec" to reuse the name of the package
  as part of the name (parsevolume.ParseVolume() -> volumespec.Parse())
- move the related compose types to the internal package as well,
  and rename them to be more generic (not associated with "compose");
  - ServiceVolumeConfig -> VolumeConfig
  - ServiceVolumeBind -> BindOpts
  - ServiceVolumeVolume -> VolumeOpts
  - ServiceVolumeImage -> ImageOpts
  - ServiceVolumeTmpfs -> TmpFsOpts
  - ServiceVolumeCluster -> ClusterOpts
- alias the internal types inside cli/compose/types to keep backward
  compatibility (for any external consumers); even though the implementation
  is internal, Go allows aliasing types to use them externally.

Signed-off-by: Michael Tews <michael@tews.dev>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-07-25 16:56:17 +02:00
644dc16b16 vendor: github.com/docker/docker master (v29.0-dev)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-07-21 23:04:50 +02:00
71bc8ab3ea Merge pull request #6186 from thaJeztah/remove_more_aliases
opts: minor cleanup in tests, and remove some import aliases
2025-07-17 17:18:15 +02:00
e95d133612 remove some redundant import aliases
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-07-16 13:56:49 +02:00
fdc90caeee cli/command/container: deprecate DiffFormatWrite
It's part of the presentation logic of the cli, and only used internally.
We can consider providing utilities for these, but better as part of
separate packages.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-07-16 13:52:04 +02:00
0db7b9f774 cli/command/container: newDiffContext: use struct-literal
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-07-16 13:50:31 +02:00
239b727834 cli/command/container: DiffFormatWrite: remove intermediate var
Also rename "ctx" argument; we shouldn't use this as name for things
that are not a context.Context.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-07-16 13:45:09 +02:00
907507e22a cli/command/container: deprecate NewDiffFormat
It's part of the presentation logic of the cli, and only used internally.
We can consider providing utilities for these, but better as part of
separate packages.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-07-16 13:45:05 +02:00
980b856816 Merge pull request #6183 from thaJeztah/diff_simplify
cli/command/container: diff: remove redundant validation and cleanup
2025-07-16 12:32:48 +02:00
9c256146ac Merge pull request #6181 from thaJeztah/fork_readCloserWrapper
remove uses of github.com/docker/docker/pkg/ioutils ReadCloserWrapper
2025-07-16 12:19:14 +02:00
3d985799d4 cli/command: remove some redundant import-aliases
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-07-16 12:12:41 +02:00
7d574b816d Merge pull request #6180 from thaJeztah/truncate_id
remove uses of github.com/docker/docker/pkg/stringid
2025-07-15 14:03:18 +02:00
0f2b709c7c cli/command/container: diff: remove redundant validation and cleanup
client.ContainerDiff already validates the given container name/ID, and
produces an error when empty, so we don't have to check for this;
abba330bbf/client/container_diff.go (L13-L16)

While updating, also;

- remove the diffOptions type, as there were no other options, and make
  the container name/ID a string argument.
- fix camelCase nameing of dockerCLI

Before this patch:

    docker diff ""
    Container name cannot be empty

With this patch:

    docker diff ""
    invalid container name or ID: value is empty

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-07-15 01:08:29 +02:00
3600ebca76 remove uses of github.com/docker/docker/pkg/ioutils ReadCloserWrapper
It was the only utility we consumed from the package, and it's trivial
to implement, so let's create local copies of it.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-07-14 22:09:31 +02:00
9b047a501f remove uses of pkg/stringid.GenerateRandomID()
This utility was only used for testing, and to generate a random
suffix for Dockerfiles. As we don't need the same contract as
pkg/stringid.GenerateRandomID() (not allow all-numeric IDs as they
would not be usable for hostnames), we can use a local test-utility,
and local implementation for the random suffix instead.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-07-14 20:11:07 +02:00
e0f4bc699c cli/command/formatter: add TrunateID utility
We were depending on pkg/stringid to truncate IDs for presentation. While
traditionally, we used a fixed length for "truncated" IDs, this is not
a strict requirement (any ID-prefix should work, but conflicts may
happen on shorter IDs).

This patch adds a local `TruncateID()` utility in the formatter package;
it's currently using the same implementation and length as the
`stringid.TruncateID` function, but may diverge in future.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-07-14 20:10:56 +02:00
0be687acc0 cli/command/container: don't set CopyToContainerOptions.AllowOverwriteDirWithFile
The `AllowOverwriteDirWithFile` option was added when reimplementing the
CLI using the API Client lib in [moby@1b2b91b]. Before that refactor, the
`noOverwriteDirNonDir` query argument [would be set unconditionally][1]
by the CLI, with no options to control the behavior.

It's unclear why the `noOverwriteDirNonDir` was implemented as opt-in (not
opt-out), as overwriting a file with a directory (or vice-versa) would
generally be unexpected behavior.

We're considering making `noOverwriteDirNonDir` unconditional on the daemon
side, and to deprecate the `AllowOverwriteDirWithFile` option. This patch
removes its use, as it was set to the default either way, and there's no
options to configure it from the CLI.

[1]: 8c9ad7b818/api/client/cp.go (L345-L346)
[moby@1b2b91b]: 1b2b91ba43

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-07-13 13:48:59 +02:00
8403869122 Merge pull request #6158 from thaJeztah/reduce_strslice
cli/command/container: remove redundant uses of strslice.StrSlice
2025-07-02 17:42:43 +02:00
e7e238eb4b cli/command/container: remove redundant uses of strslice.StrSlice
The strslice.StrSlice type is a string-slice with a custom JSON Unmarshal
function to provide backward-compatibility with older API requests (see
[moby@17d6f00] and [moby@ea4a067]).

Given that the type is assigned implicitly through the fields on HostConfig,
we can just use a regular []string instead.

[moby@17d6f00]: 17d6f00ec2
[moby@ea4a067]: ea4a06740b

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-07-01 10:09:54 +02:00