Commit Graph

10765 Commits

Author SHA1 Message Date
8bedb69f2c cli-plugins/manager: move OTEL-related code to separate file
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-03 14:24:00 +01:00
9dc175d6ef cli/command: un-export ResourceAttributesEnvvar, DockerCliAttributePrefix
These utility functions were added in 8890a1c929,
and are all related to OTEL. The ResourceAttributesEnvvar const defines
the "OTEL_RESOURCE_ATTRIBUTES" environment-variable to use, which is part
of the [OpenTelemetry specification], so should be considered a well-known
env-var, and not up to us to define a const for. These code-changes were not
yet included in a release, so we don't have to deprecate.

This patch:

- Moves the utility functions to the telemetry files, so that all code related
  to OpenTelemetry is together.
- Un-exports the ResourceAttributesEnvvar to reduce our public API.
- Un-exports the DockerCliAttributePrefix to reduce depdency on cli/command
  in CLI-plugins, but adds a TODO to move telemetry-related code to a common
  (internal) package.
- Deprecates the cli-plugins/manager.ResourceAttributesEnvvar const. This
  const has no known consumers, so we could skip deprecation, but just in
  case some codebase uses this.

[OpenTelemetry specification]: https://opentelemetry.io/docs/specs/otel/configuration/sdk-environment-variables/#general-sdk-configuration

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-03 14:21:45 +01:00
43a2fcf5d7 Merge pull request #5880 from thaJeztah/registry_decouple_trust
cli/registry/client: remove dependency on trust / notary
2025-03-03 12:49:54 +01:00
e3da0cc584 cli/registry/client: remove dependency on trust / notary
The client was only using the Actions consts, but the trust package
also has a dependency on notary. Remove the import to prevent Notary
becoming a dependency for uses of the cli code.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-03 12:19:20 +01:00
076ec3b56e Merge pull request #5878 from thaJeztah/trust_cleans
Assorted cleanups to reduce trust / notary imports
2025-03-03 12:18:47 +01:00
124716ba6b Merge pull request #5879 from thaJeztah/google_uuid
cli/command: remove dependency on distribution/uuid
2025-03-03 12:18:19 +01:00
fda7da2303 cli/command: remove dependency on distribution/uuid
This uuid package was introduced in 89db01ef97,
but we want to reduce dependency on the old docker/distribution module.

Replace it with google/uuid, which is a commonly used module for this
and already a dependency.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-03 11:41:17 +01:00
3f154adf70 Merge pull request #5877 from thaJeztah/remove_redundant_ParseRepositoryInfo
cli/command/manifest: remove redundant uses of ParseRepositoryInfo
2025-03-03 11:36:16 +01:00
c7072a885d cli/command/image: rename vars that shadowed type
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-02 14:16:38 +01:00
7a6270d190 cli/command/image: move AddTargetToAllSignableRoles to cli/trust
This utility was shared between the "image" and "trust" packages, and a
shallow wrapper around features in the cli/trust package. Move it there
instead and rename it to `trust.AddToAllSignableRoles`.

There are no known external consumers of this utility, so skipping a
deprecation.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-02 14:16:38 +01:00
d95385057f cli/command/trust: use gotest.tools in tests
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-02 14:16:37 +01:00
e6382db10e cli/command/image: move trust unit-tests to trust package
These tests were not testing functionality that was implemented
in the image package. Move them to the trust package, where
they belong.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-02 14:16:37 +01:00
55bc30a784 cli/command/image: use t.SetEnv in trust tests
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-02 14:16:37 +01:00
049f84c94d cli/command/image: remove TestAddTargetToAllSignableRolesError
This test was only testing trust.GetSignableRoles to return an error
if it's offline, which was duplicating the [TestGetSignableRolesError]
test in the cli/trust package.

[TestGetSignableRolesError]: fe0a8d2791/cli/trust/trust_test.go (L49-L55)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-02 14:16:37 +01:00
791bdf7b3c cli/command/trust: add testPassRetriever helper
Add a basic helper to provide the equivalent of passphrase.ConstantRetriever
with a fixed passphrase for testing.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-02 14:16:32 +01:00
1d8f87a2fb cli/command/trust: remove TestGetSignableRolesForTargetAndRemoveError
This test was only testing trust.GetSignableRoles to return an error
if it's offline, which was duplicating the [TestGetSignableRolesError]
test.

[TestGetSignableRolesError]: fe0a8d2791/cli/trust/trust_test.go (L49-L55)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-02 14:16:04 +01:00
d4217eb205 cli/command/trust: remove TestGetOrGenerateNotaryKeyAndInitRepo
This test was only testing trust.GetSignableRoles to return an error
if it's offline, which was duplicating the [TestGetSignableRolesError]
test.

[TestGetSignableRolesError]: fe0a8d2791/cli/trust/trust_test.go (L49-L55)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-02 14:16:04 +01:00
dd617b1464 cli/command/trust: remove unused passphrase-retriever from test
The test only validates that an error is produced because the notary
server is offline, and does not sent a passphrase.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-02 14:16:04 +01:00
eae4c38023 internal/test/notary: add testPassRetriever helper
Add a basic helper to provide the equivalent of passphrase.ConstantRetriever
with a fixed passphrase for testing.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-02 14:15:57 +01:00
eb82fe87a5 cli/trust: make NotaryServer a const
This var used to be vendored from github.com/docker/docker/registry, but was
removed there, and made a local var in a1cbaa827b.

It is (and should never be) modified, so let's change it into a const.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-02 12:42:13 +01:00
55a83aff23 cli/command/manifest: remove redundant uses of ParseRepositoryInfo
[ParseRepositoryInfo] parses an image reference and returns information
about the Repository and the registry. As part of this, it validates if
the registry's hostname is considered valid using [ValidateIndexName],
as well as normalizing the image reference to strip tags and digests
using [reference.TrimNamed].

ValidateIndexName only provides very limited value; the only validation
happening is to check for the hostname to not start, or end with a hyphen.

The cli/command/manifest package used ParseRepositoryInfo in various
locations where only the repository name was used (i.e., the result
of `reference.TrimNamed` on the given reference), and in one location
only used it to validate the registry name.

For buildPushRequest, the call was fully redundant, as [RepoNameForReference]
was used on the result, calling [newDefaultRepositoryEndpoint], which
uses ParseRepositoryInfo internally, so we were only repeating that work.

This patch removes uses of ParseRepositoryInfo in those places, and instead
calling [reference.TrimNamed] directly.

[ParseRepositoryInfo]: 41f781fab3/registry/config.go (L375-L381)
[ValidateIndexName]: 41f781fab3/registry/config.go (L288-L299)
[reference.TrimNamed]: 41f781fab3/registry/config.go (L369)
[RepoNameForReference]: fe0a8d2791/cli/registry/client/endpoint.go (L107-L110)
[newDefaultRepositoryEndpoint]: fe0a8d2791/cli/registry/client/endpoint.go (L33-L38)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-01 15:40:29 +01:00
fe0a8d2791 Merge pull request #5842 from jsternberg/otel-resource-attributes-merge
cli-plugins: merge OTEL_RESOURCE_ATTRIBUTES environment variable
2025-02-28 10:45:17 +01:00
b414752ef8 Merge pull request #5851 from thaJeztah/err_handle_explicit
explicitly handle errors when wrapping them
2025-02-26 16:23:35 +01:00
7b78eabcab Merge pull request #5872 from vvoland/vendor-docker
vendor: github.com/docker/docker v28.0.1
2025-02-26 15:40:13 +01:00
9e997a57fa vendor: github.com/docker/docker v28.0.1
full diff: https://github.com/docker/docker/compare/af898abe4466...v28.0.1

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-02-26 15:32:31 +01:00
068a01ea94 Merge pull request #5870 from thaJeztah/carry_5855
Add detailed descriptions for --ulimit options in docker run documentation
2025-02-25 18:52:55 +01:00
d75f8d83d3 Add detailed descriptions for --ulimit options in docker run documentation
Signed-off-by: MHM0098 <mhm98035@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-25 16:15:21 +01:00
ffdfc5f94d Merge pull request #5742 from mertssmnoglu/fix-dockerfile-exec-form
fix/dockerfiles: Update CMD instruction in 'Dockerfile.dev' to use exec form
2025-02-25 15:59:09 +01:00
6bd9908388 Merge pull request #5867 from thaJeztah/bump_go_jose
vendor: github.com/go-jose/go-jose/v4 v4.0.5
2025-02-25 13:03:21 +00:00
75595836f2 vendor: github.com/go-jose/go-jose/v4 v4.0.5
- Don't allow unbounded amounts of splits.
  Fixes GHSA-c6gw-w398-hv78 / CVE-2025-27144
- Various other dependency updates, small fixes, and documentation
  updates in the full changelog

full diff: https://github.com/go-jose/go-jose/compare/v4.0.4...v4.0.5

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-25 11:55:06 +01:00
41277f53d5 Merge pull request #5865 from robmry/doc_default_bridge
Update dockerd command line ref
2025-02-24 18:14:39 +00:00
4e7497e9cf Update dockerd command line ref, default bridge opts
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-02-24 18:07:06 +00:00
be669099cb Update dockerd command line ref, changes in 28.0
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-02-24 18:07:06 +00:00
111468ccd6 Merge pull request #5864 from thaJeztah/gha_bump_docker
gha: add docker 28 to test matrix
2025-02-24 16:39:27 +00:00
427c1361c5 gha: add docker 28 to test matrix
- set default to 28
- remove minor version from matrix; docker:dind images also provide a
  "docker:28-dind" which point to the latest minor version.
- remove TODO for 19.03, which is really out of scope now.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-24 15:14:53 +01:00
656523e20d Merge pull request #5859 from thaJeztah/fix_docs
docs: minor fixes and touch-ups for anchor links
2025-02-24 12:05:34 +01:00
aad2ae50e8 docs: network ls add heading and anchor for "--no-trunc"
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-21 23:51:04 +01:00
8a1b096e76 docs: fix missing anchors in swarm reference pages
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-21 23:46:07 +01:00
c99d3312eb docs: fix broken anchor-link in "container restart" reference
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-21 23:45:32 +01:00
77a8a8c6ca Merge pull request #5854 from Benehiko/fix-exec-msg
cmd/docker: do not print error status on exec/run
2025-02-21 12:20:31 +00:00
0cff340983 cmd/docker: do not print error status on exec/run
Co-authored-by: Fabio Pugliese Ornellas <fabio.ornellas@gmail.com>
Signed-off-by: Alano Terblanche <18033717+Benehiko@users.noreply.github.com>
2025-02-21 12:55:57 +01:00
eb48cad302 Merge pull request #5848 from thaJeztah/improve_swarm_completion
completion: fix / add completion for service names and node-names
2025-02-20 12:24:31 -07:00
2493a96027 Merge pull request #5850 from thaJeztah/fix_context_err
cli/command/context: fix error-handling of skip-tls-verify
2025-02-20 18:37:04 +01:00
8f55738579 completion: add completion for docker service flags
Not all flags have completions yet, and for those that don't have completion,
we disable completion to prevent it completing with filenames.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-20 18:33:17 +01:00
768d10767f completion: add completion for docker node flags
With this patch:

    docker node update --role
    manager  worker

    docker node update --availability
    active  drain   pause

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-20 18:33:17 +01:00
d5e6e2ec6e completion: add completion for node names
Change completion for nodes to use names by default, and bring back
support for the `DOCKER_COMPLETION_SHOW_NODE_IDS` env-var
f9ced58158/contrib/completion/bash/docker (L38)

With this patch:

    docker node ps <tab>
    docker-desktop            self

    export DOCKER_COMPLETION_SHOW_NODE_IDS=yes
    docker node ps <TAB>
    docker-desktop             qyeriqk20al6hy4y869d08ff5  self

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-20 18:33:09 +01:00
da4b6275ba explicitly handle errors when wrapping them
The errors.Wrap and errors.Wrapf functions gracefully handle nil-errors.
This allows them to be used unconditionally regardless if an error
was produced.

While this can be convenient, it can also be err-prone, as replacing
these with stdlib errors means they unconditionally produce an error.

This patch replaces code uses of errors.Wrap to be gated by a check
for nil-errors to future-proof our code.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-20 18:10:36 +01:00
7e71782ba6 cli/command/context: fix error-handling of skip-tls-verify
Before 2b9a4d5f4c, this function
would use "errors.Wrap" which returns nil if the original error
was nil. fmt.Errorf does not do this, so without a nil check,
it would unconditionally return an error;

    docker context create arm64 --docker host=ssh://172.17.101.26,skip-tls-verify=False

    unable to create docker endpoint config: name: %!w(<nil>)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-20 17:49:58 +01:00
762d59359e completion: use service names, and support DOCKER_COMPLETION_SHOW_SERVICE_IDS
Change completion for services to use names by default, and bring back
support for the `DOCKER_COMPLETION_SHOW_SERVICE_IDS` env-var
f9ced58158/contrib/completion/bash/docker (L41-L43)

Before this patch:

    docker service ps
    c9vrp2pwni9gx5ghat20rjpcy  hmthf0tqws9xpmd87ok7diqly

With this patch:

    docker service ps<TAB>
    databaseservice  webservice

    export DOCKER_COMPLETION_SHOW_SERVICE_IDS=yes
    docker service ps<TAB>
    c9vrp2pwni9gx5ghat20rjpcy  databaseservice            hmthf0tqws9xpmd87ok7diqly  webservice

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-20 13:51:38 +01:00
f9ced58158 Merge pull request #5845 from vvoland/vendor-docker
vendor: github.com/docker/docker v28.0.0-dev (af898abe4466)
2025-02-19 22:05:47 +00:00