Commit Graph

1565 Commits

Author SHA1 Message Date
Laura Brehm 23a8d38e25
volume/update: require 1 argument/fix panic
This command was declaring that it requires at least 1 argument, when it
needs exactly 1 argument. This was causing the CLI to panic when the
command was invoked with no argument:

`docker volume update`

Signed-off-by: Laura Brehm <laurabrehm@hey.com>
(cherry picked from commit daea277ee8)
Signed-off-by: Austin Vazquez <macedonv@amazon.com>
2024-10-08 04:53:08 +00:00
Nick Sieger 5bab750c2b
cli/command: more go1.19 ("predeclared any")
Signed-off-by: Nick Sieger <nick@nicksieger.com>
(cherry picked from commit d0057db3ac)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-13 23:52:54 +02:00
Sebastiaan van Stijn b600054c51
migrate to new github.com/containerd/platforms package
The github.com/containerd/containerd/platforms package was moved to a separate
module in preparation of the containerd v2.0 release.

Switch to the new module, which means we also remove containerd as a direct
dependency.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 7dc271a8be)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-03 17:45:45 +02:00
Sebastiaan van Stijn 258e27438f
context list: temporarily add ContextType to JSON output
Docker Desktop currently ships with the "cloud integration" wrapper,
which outputs an additional ContextType field in the JSON output.

While this field is non-standard, it made its way into Visual Studio's
Docker integration, which uses this to exclude "aci" and "eci" context
types that are not supported by Visual Studio.

This patch;

- conditionally adds a ContextType field to the JSON output
- but ONLY when using the default "{{json .}}" or "json" formats
  (which are the formats used by Visual Studio)
- if the context is a "aci" or "eci" context, that type is
  preserved, otherwise the default "moby" type is used.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit fed9fa0f72)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-05-31 14:48:35 +02:00
Sebastiaan van Stijn 29cd8591ee
cli/command/context: list: add test for JSON output
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 40a1da8b42)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-05-31 14:48:19 +02:00
Sebastiaan van Stijn e23a63eb4c
cli/command/context: test inspecting context with custom metadata
The CLI does not currently expose options to add custom metadata to
contexts, but contexts support them.

- update test-utilities to allow setting custom metadata
- update the inspect test to verify that custom metadata is included
  when inspecting a context.
- update the import/export tests to verify that custom metadata
  is preserved.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 2e9eff235d)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-05-31 14:48:19 +02:00
Sebastiaan van Stijn 1e52a86d42
cli/command/context: add test-utility to create multiple contexts
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 54291dd47a)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-05-31 14:48:16 +02:00
Laura Brehm 326c7138bb
OTel: implement missing MeterProvider `ForceFlush`
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
(cherry picked from commit 5f4f4f64d3)
2024-05-15 02:00:06 +01:00
Laura Brehm ee359a394b
OTel: add `command.time` metric to plugin commands
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
(cherry picked from commit f07834d185)
2024-05-15 02:00:05 +01:00
Christopher Petito 6691085012
Use funcs on DockerCli to return Meter/TracerProviders, not initialize them. Initialize them during DockerCli struct init
Signed-off-by: Christopher Petito <chrisjpetito@gmail.com>
(cherry picked from commit 02537eac59)
2024-05-14 16:31:06 +01:00
Laura Brehm ccea7d8a30
Fix hang when container fails to start
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
(cherry picked from commit 31644d5ea7)
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2024-05-07 11:57:24 +01:00
Paweł Gronowski 840016ea05
waitExitOrRemoved: Handle context cancellation
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-04-29 16:46:11 +02:00
Christopher Petito d6796c002f Fix OTLP env var overriding
Signed-off-by: Christopher Petito <chrisjpetito@gmail.com>
2024-04-17 14:32:41 +00:00
Laura Brehm cefcba9871
otel: capture exit code as int64
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2024-04-04 19:11:56 +01:00
Bjorn Neergaard 10b9810989
Merge pull request #4978 from laurazard/otel-add-tty
otel: capture whether process was invoked from a terminal
2024-04-04 06:09:48 -06:00
Laura Brehm ee1b2836af
otel: capture whether process was invoked from a terminal
This commit adds a "terminal" attribute to `BaseMetricAttributes`
that allows us to discern whether an invocation was from an interactive
terminal or not.

Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2024-04-04 03:28:17 +01:00
Sebastiaan van Stijn 9ca30bd2ac
Merge pull request #4939 from Benehiko/prompt-termination
feat: standardize error for prompt
2024-04-02 19:09:12 +02:00
Alano Terblanche 910d5d0247
chore: remove backticks and resolve linting issues
Signed-off-by: Alano Terblanche <18033717+Benehiko@users.noreply.github.com>
2024-04-02 15:54:29 +02:00
Jonathan A. Sternberg 2a3b6c03f7
cli: add go:build tag to the docker telemetry
This is needed because the project does not have a `go.mod` file and
gets sent to go 1.16 semantics whenever it's imported by another project
and `any` doesn't exist in go 1.16, but the linter requires us to use
`any` here.

Setting the `go:build` tag forces the per-file language to the go
version specified.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2024-03-28 14:09:34 -05:00
Christopher Petito b6e2eca4b8 Enable overriding of the otel exporter otlp endpoint via env var for testing purposes
Signed-off-by: Christopher Petito <chrisjpetito@gmail.com>
2024-03-28 16:22:53 +00:00
Christopher Petito 160f65d9db Added some telemetry utils
Signed-off-by: Christopher Petito <chrisjpetito@gmail.com>
2024-03-28 16:22:43 +00:00
Alano Terblanche 7c722c08d0
feat: standardize error for prompt
Signed-off-by: Alano Terblanche <18033717+Benehiko@users.noreply.github.com>
2024-03-26 14:11:55 +01:00
Laura Brehm b8d5454963
Merge pull request #4957 from Benehiko/prompt-test-flakiness
fix: flaky prompt termination on reader close test
2024-03-26 13:03:02 +00:00
Alano Terblanche 7ea10d5ced
refactor: prompt tests
Signed-off-by: Alano Terblanche <18033717+Benehiko@users.noreply.github.com>
2024-03-26 10:07:01 +01:00
Jonathan A. Sternberg 89db01ef97
cli: add otel sdk tracing and metric providers to the core cli
This adds the code used by buildx and compose into the default CLI
program to help normalize the usage of these APIs and allow code reuse
between projects. It also allows these projects to benefit from
improvements or changes that may be made by another team.

At the moment, these APIs are a pretty thin layer on the OTEL SDK. It
configures an additional exporter to a docker endpoint that's used for
usage collection and is only active if the option is configured in
docker desktop.

This also upgrades the OTEL version to v1.19 which is the one being used
by buildkit, buildx, compose, etc.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2024-03-25 11:11:34 -05:00
Bjorn Neergaard 799bf52680
Merge pull request #4376 from laurazard/plugin-hooks
Introduce support for CLI plugin hooks
2024-03-22 14:34:14 -06:00
Laura Brehm c5016c6d5b
cli-plugins: Introduce support for hooks
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2024-03-22 17:30:18 +00:00
Alano Terblanche d2ea5adfe4
fix: flaky prompt termination on reader close test
Signed-off-by: Alano Terblanche <18033717+Benehiko@users.noreply.github.com>
2024-03-21 10:53:30 +01:00
Paweł Gronowski 23563728bc
Merge pull request #4944 from thaJeztah/update_engine
vendor: github.com/docker/docker 70e46f2c7c2d (v26.0.0-rc3-dev)
2024-03-19 11:00:31 +01:00
Sebastiaan van Stijn 48b5efee03
Dockerfile: update mvdan/gofumpt to v0.6.0
- full diff: https://github.com/mvdan/gofumpt/compare/v0.4.0...v0.6.0
- v0.6.0 release notes: https://github.com/mvdan/gofumpt/releases/tag/v0.6.0
- v0.5.0 release notes: https://github.com/mvdan/gofumpt/releases/tag/v0.5.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-03-17 13:48:13 +01:00
Sebastiaan van Stijn 38c3ff67aa
vendor: github.com/docker/docker 70e46f2c7c2d (v26.0.0-rc3-dev)
full diff: https://github.com/docker/docker/compare/v26.0.0-rc2...70e46f2c7c2df8d8cc483d9831a907b12efa201b

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-03-16 16:53:20 +01:00
Sebastiaan van Stijn 46afd26c45
cli/command: deprecate EventHandler and InitEventHandler
This code was only used as part of container.RunStats, so moving the code
there instead as a non-exported type. The actual use also did not have to
handle concurrency, so the mutex is removed in the new location.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-03-11 13:25:22 +01:00
Sebastiaan van Stijn 5c54f75f2a
cli/command/container: use ping-result for OS-version
The daemonOSType variable is already set when collecting stats, so we unlikely
hit this code in practice, and it would only be set if `collect()` failed and
we never got a stats response. If we do need to get this information, let's use
the OSVersion we already obtained from the ping response.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-03-11 11:05:56 +01:00
Alano Terblanche 10bf91a02d
fix: cli prompt termination exit code
Signed-off-by: Alano Terblanche <18033717+Benehiko@users.noreply.github.com>
2024-03-04 15:26:17 +01:00
George Margaritis 238d659ff9
Add support for --detach/-d flag in stack rm
Added --detach/-d to stack rm. Setting --detach=false waits until
all of the stack tasks have reached a terminal state.

Co-authored-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: George Margaritis <gmargaritis@protonmail.com>
2024-03-04 09:56:53 +01:00
George Margaritis b086d72769
Add support for --detach flag in stack deploy
Added --detach and --quiet/-q flags to stack deploy. Setting --detach=false
waits until all of the stack services have converged. Shows progress bars for
each individual task, unless  --quiet/-q is specified.

Co-authored-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: George Margaritis <gmargaritis@protonmail.com>
2024-03-04 09:36:36 +01:00
Paweł Gronowski 5e80232398
vendor: github.com/docker/docker v26.0.0-rc1
full diff: https://github.com/docker/docker/compare/c70d7905fbd9...v26.0.0-rc1

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>

test: update fixtures

Signed-off-by: Alano Terblanche <18033717+Benehiko@users.noreply.github.com>
2024-03-01 18:23:25 +01:00
Christopher Petito 69e0f53a03 Uniform volume prune output msg with other prune commands
- Return error when user refuses at confirmation prompt
- Avoid sending space freed msg if user cancelled
- Fixed unit tests

Signed-off-by: Christopher Petito <chrisjpetito@gmail.com>
2024-02-06 14:04:53 +00:00
Sebastiaan van Stijn 809eb8cdee
images: print hint when invoking "docker images" with ambiguous argument
The `docker images` top-level subcommand predates the `docker <object> <verb>`
convention (e.g. `docker image ls`), but accepts a positional argument to
search/filter images by name (globbing). It's common for users to accidentally
mistake these commands, and to use (e.g.) `docker images ls`, expecting
to see all images, but ending up with an empty list because no image named
"ls" was found.

Disallowing these search-terms would be a breaking change, but we can print
and informational message to help the users correct their mistake.

Before this patch:

    docker images ls
    REPOSITORY   TAG       IMAGE ID   CREATED   SIZE

With this patch applied:

    docker images ls
    REPOSITORY   TAG       IMAGE ID   CREATED   SIZE

    No images found matching "ls": did you mean "docker image ls"?

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-02-03 18:10:55 +01:00
Sebastiaan van Stijn b158181a1d
cli/command/images: runImages: use proper camel-case for dockerCLI
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-02-03 17:56:06 +01:00
Sebastiaan van Stijn 1328bb3381
cli/command/images: runImages: inline intermediate var
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-02-03 17:54:23 +01:00
Sebastiaan van Stijn dfdff11a22
cli/command: don't use pflags.XXXVarP for flags without shorthand
Use the `XXXVar` equivalent for flags that don't have a shorthand flag
instead of passing an empty string for the shorthand flag.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-01-29 11:16:38 +01:00
Sebastiaan van Stijn 690f63e6d3
cli/command/container: minor cleanup in attach
- rename confusing `target` argument, and use `containerID` in all places;
  also make the variable more clearly local-scoped.
- rename `dockerCli` to be correctly camel-case, and to be consistent in
  all places in this file.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-01-26 13:38:09 +01:00
Paweł Gronowski 4fa2fe9b9e
Replace deprecated types.Image* usage
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-01-24 14:59:10 +01:00
Sebastiaan van Stijn d9294f06b5
info: remove printSecurityOptionsWarnings, printServerWarnings
Docker Engine 1.13 (API v1.25) added an option to set a custom default seccomp
profile on the daemon (see [moby/moby@b237189]). A warning was added on the
client-side if a non-default profile was set.

Docker Engine 23.0 (API v1.42) added warnings about non-default seccomp
profiles to the "info" response ([moby/moby@04f932a]), and the client was
updated to skip generating client-side warnings for API v1.42 and up in
[docker/cli@8964595].

These warnings are purely informational, and given that Docker Engine versions
before 23.0 have reached EOL, and any current version of the Engine now returns
the Warnings, it should be safe to remove the client-side fall back logic.

This patch removes the client-side fall back code for warnings that was
added in 8964595692.

[moby/moby@b237189]: b237189e6c
[moby/moby@04f932a]: 04f932ac86
[docker/cli@8964595]: 8964595692

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-01-23 18:23:35 +01:00
Sebastiaan van Stijn c6ae74956c
Merge pull request #4808 from thaJeztah/remove_printServerWarningsLegacy
info: remove printServerWarningsLegacy
2024-01-23 18:22:58 +01:00
Sebastiaan van Stijn 69a4fcc3bb
Merge pull request #4810 from thaJeztah/remove_deprecated_cliopts
cli/command: remove deprecated DockerCliOption, InitializeOpt
2024-01-23 18:22:28 +01:00
Sebastiaan van Stijn 2402dac819
cli/command/container: remove deprecated NewStartOptions
This function was deprecated in 298bddcc23 for
v25.0, and unused. This patch removes the function.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-01-20 21:48:46 +01:00
Sebastiaan van Stijn b43377a38b
cli/command: remove deprecated DockerCliOption, InitializeOpt
These types were deprecated in 7af509c7f1 (v25.0),
in favor of CLIOption, and are no longer used.

This patch removes the deprecated type-aliases, and while updating, also improves
the documentation for the CLIOption type.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-01-20 21:39:32 +01:00
Sebastiaan van Stijn a71d39bcad
info: remove printServerWarningsLegacy
Docker Engine 18.09 (API v1.39) introduced a Warnings field in the into response.
This enhancement was not gated by API version (see [moby/moby@a3d4238]), and
will be returned by Docker Engine 18.09 and up, regardless of the API version
chosen.

Likewise, the client-side code was written to prefer warnings returned by
the daemon, but to fall back on client-side detection of missing features
based on information in the Info response (see [docker/cli@3c27ce2]).

Thse warnings are purely informational, and given that Docker Engine versions
before 18.09 have reached EOL 6 Years ago, and any current version of the
Engine now returns the Warnings, it should be safe to remove the client-side
fall back logic.

This patch removes the client-side fall back code for warnings that was
added in 3c27ce21c9.

[moby/moby@a3d4238]: a3d4238b9c
[docker/cli@3c27ce2]: 3c27ce21c9

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-01-20 20:45:59 +01:00