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

3 Commits

Author SHA1 Message Date
Sebastiaan van Stijn
570a17b3bc internal/commands: RegisterLegacy: remove redundant copy
The RegisterLegacy and Register functions register constructors for
commands, so we should expect them to be a fresh copy that is not
shared, which means that we can mutate the command in-place.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-08-21 10:47:26 +02:00
Sebastiaan van Stijn
4405c0bd50 internal/commands: remove mutexes / synchronisation
The Register and RegisterLegacy functions are designed to be used
in package init() functions, which are guaranteed to be run
sequentially.

From the documentation (https://go.dev/ref/mem#init);

> Program initialization runs in a single goroutine, but that goroutine
> may create other goroutines, which run concurrently. If a package `p`
> imports package `q`, the completion of `q`'s `init` functions happens
> before the start of any of `p`'s.
>
> The completion of all `init` functions is synchronized before the
> start of the function `main.main`.

This patch removes the synchonisation as no concurrency should happen
if these functions are used as intended.

As the internal queue is not expected to be mutated after use, we also
don't have to return a copy.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-08-21 10:42:02 +02:00
Alano Terblanche
4ead8784d0 Add command registration helpers
This patch adds helper methods to the CLI to register cobra commands.

Signed-off-by: Alano Terblanche <18033717+Benehiko@users.noreply.github.com>
2025-08-18 16:56:35 +02:00