Commit Graph

10802 Commits

Author SHA1 Message Date
44e5100232 move winresources into cmd/docker
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-08 22:20:09 +01:00
2eec74659e Merge pull request #5901 from NinaLua/master
chore: make function comment match function name
2025-03-07 20:42:38 +01:00
e201b4e8a5 Merge pull request #5902 from thaJeztah/cli_plugin_metadata
move cli-plugins metadata types/consts to a separate package
2025-03-07 19:13:02 +01:00
292713c887 move cli-plugins annotation consts to a separate package
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-07 12:46:11 +01:00
4321293972 move cli-plugins metadata types/consts to a separate package
This prevents cli-plugins having to import the plugin-manager.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-07 12:38:06 +01:00
aa66f07a3e chore: make function comment match function name
Signed-off-by: NinaLua <iturf@sina.cn>
2025-03-07 14:21:27 +08:00
ceef542046 Merge pull request #5894 from thaJeztah/more_internalize
move some trust-related code to trust package
2025-03-06 18:10:20 +01:00
f9b3c8ce10 Merge pull request #5875 from thaJeztah/bump_creds_helper_0.9.0
vendor: github.com/docker/docker-credential-helpers v0.9.2
2025-03-06 00:34:34 +01:00
b2a669fb56 vendor: github.com/docker/docker-credential-helpers v0.9.2
full diff: https://github.com/docker/docker-credential-helpers/compare/v0.8.2...v0.9.2

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-05 22:38:56 +01:00
e37d814ce9 cli/command/image: deprecate TagTrusted, move to cli/trust
This function was shared between "image" and "container" packages,
all of which needed the trust package, so move it there instead.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-05 21:36:53 +01:00
d80436021c cli/command/image: deprecate PushTrustedReference, move to trust
This function was shared between "trust" "image" and "plugin" packages,
all of which needed the trust package, so move it there instead.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-05 18:29:12 +01:00
c6f456bc90 cli/command/image: deprecate and internalize TrustedPush
This function was only used by "docker trust sign"; inline the code
and deprecate the function.

This function has no known external consumers, so we should remove
it on the first possible ocassion (which could be a minor release).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-05 18:29:08 +01:00
e558b915c2 Merge pull request #5892 from thaJeztah/pluginmanager_smaller_interface
cli-plugins/manager: use shallower interface
2025-03-05 13:18:57 +01:00
a9e530999e Merge pull request #5893 from thaJeztah/hooks_optim
small performance optimizations for running hooks
2025-03-05 12:59:04 +01:00
a89a15a85c Merge pull request #5890 from vvoland/update-go
update to go1.23.7
2025-03-05 12:56:31 +01:00
4be2ddedd3 cli/command: Cli: embed config.Provider interface
Makes sure we implement that interface, and don't diverge.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-05 12:05:56 +01:00
8dcde50b6e cli-plugins/manager: use shallower interface
The manager only requires the CLI's configuration; define a shallow interface
for this so that we don't have to import cli/command.

In addition to the CLI's configuration, `runHooks` also used the CLI's configured
StdErr output. We set the Cobra input and output streams to be the same as the
DockerCLI outputs in [newDockerCommand] and [newPluginCommand], so we can
get this from the Cobra command.

[newDockerCommand]: ea1f10b440/cmd/docker/docker.go (L148-L150)
[newPluginCommand]: ea1f10b440/cli-plugins/plugin/plugin.go (L166-L168)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-05 12:04:49 +01:00
6d551e0a5a cli/command: DockerCli.HooksEnabled check current before legacy
The DOCKER_CLI_HINTS env-var is replaced by DOCKER_CLI_HOOKS; check the
new env-var first, and only fall back to checking the legacy env-var
if it's not set.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-05 11:52:01 +01:00
a2d78071c1 cmd/docker: small performance optimizations for running hooks
Order conditions to check for lightweight ones first;

- checck if the command is not nil
- dockerCli.Out().IsTerminal() is a lightweight getter
- dockerCli.HooksEnabled() checks for env-vars, parses booleans, and
  reading the CLI config-file

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-05 11:51:58 +01:00
df209212cf update to go1.23.7
- https://github.com/golang/go/issues?q=milestone%3AGo1.23.7+label%3ACherryPickApproved
- full diff: https://github.com/golang/go/compare/go1.23.6...go1.23.7

These minor releases include 1 security fixes following the security policy:

net/http, x/net/proxy, x/net/http/httpproxy: proxy bypass using IPv6 zone IDs

Matching of hosts against proxy patterns could improperly treat an IPv6
zone ID as a hostname component. For example, when the NO_PROXY
environment variable was set to "*.example.com", a request to
"[::1%25.example.com]:80` would incorrectly match and not be proxied.

Thanks to Juho Forsén of Mattermost for reporting this issue.

This is CVE-2025-22870 and Go issue https://go.dev/issue/71984.

View the release notes for more information:
https://go.dev/doc/devel/release#go1.23.7

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-03-04 22:59:28 +01:00
ea1f10b440 Merge pull request #5889 from thaJeztah/internalize_manifest
cli/command: deprecate Cli.ManifestStore, Cli.RegistryClient
2025-03-04 20:31:55 +01:00
7bcbe0837b Merge pull request #5888 from thaJeztah/command_no_go_connections
cli/command: remove direct import of docker/go-connections
2025-03-04 20:30:53 +01:00
0b985e74f1 Merge pull request #5881 from thaJeztah/cleanup_otel
cli/command: un-export ResourceAttributesEnvvar, DockerCliAttributePrefix
2025-03-04 18:14:50 +01:00
95ac11e714 cli/command: remove direct import of docker/go-connections
It was only used to check if the value was nil; pass a boolean instead.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-04 18:00:58 +01:00
8ad07217dc cli/command: deprecate Cli.RegistryClient
This method was a shallow wrapper around registryclient.NewRegistryClient but
due to its signature resulted in various dependencies becoming a dependency
of the "command" package. Consequence of this was that cli-plugins, which
need the cli/command package, would also get those dependencies. It is no
longer used in our code, which constructs the client in packages that need it,
so we can deprecate this method.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-04 17:48:43 +01:00
e32d5d56f5 cli/command: deprecate Cli.ManifestStore
This method is a shallow wrapper around manifeststore.NewStore, but
due to its signature resulted in various dependencies becoming a dependency
of the "command" package. Consequence of this was that cli-plugins, which
need the cli/command package, would also get those dependencies. It is no
longer used in our code, which constructs the client in packages that need it,
so we can deprecate this method.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-04 17:48:43 +01:00
985b58e7e1 cli/command: internalize constructing RegistryClient
The CLI.RegistryClient method is a shallow wrapper around registryclient.NewRegistryClient
but due to its signature resulted in various dependencies becoming a dependency
of the "command" package. Consequence of this was that cli-plugins, which
need the cli/command package, would also get those dependencies.

This patch inlines the code where needed, skipping the wrapper

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-04 17:48:42 +01:00
3b5dff2783 cli/command: internalize constructing ManifestStore
The CLI.ManifestStore method is a shallow wrapper around manifeststore.NewStore
and has no dependency on the CLI itself. However, due to its signature resulted
in various dependencies becoming a dependency of the "command" package.
Consequence of this was that cli-plugins, which need the cli/command package,
would also get those dependencies.

- This patch inlines the code to produce the store, skipping the wrapper.
- Define a local interface for some tests where a dummy store was used.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-04 17:48:42 +01:00
c775585e6c Merge pull request #5885 from thaJeztah/internalize_notaryclient
cli/command: internalize and deprecate Cli.NotaryClient
2025-03-04 17:48:17 +01:00
9bc16bbde0 cli/command: deprecate Cli.NotaryClient
This method is a shallow wrapper around trust.GetNotaryRepository, but
due to its signature resulted in the trust package, and notary dependencies
to become a dependency of the CLI. Consequence of this was that cli-plugins,
which need the cli/command package, would also get notary and its
dependencies as a dependency. It is no longer used in our code, which
constructs the client in packages that need it, so we can deprecate this
method.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-04 17:40:08 +01:00
2793731977 cli/command: internalize constructing Notary client
The CLI.NotaryClient method is a shallow wrapper around trust.GetNotaryRepository
and only depends on the CLI itself to pass its StdErr/StrOut streams.

- This patch inlines the code to produce the client, skipping the wrapper.
- Define a local interface for some tests where a dummy notary client was used.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-04 17:40:06 +01:00
539f6de682 Merge pull request #5887 from thaJeztah/gha_bump_ubuntu
gha: validate-pr: update to ubuntu 24.04
2025-03-04 17:39:16 +01:00
cdc2cdc2a8 gha: validate-pr: update to ubuntu 24.04
Github is phasing out Ubuntu 20.04, and currently is doing
brownouts; https://github.com/actions/runner-images/issues/11101

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-04 17:00:14 +01:00
d962a90517 Merge pull request #5882 from thaJeztah/regclient_cleanup
cli/registry/client: remove unused types, and deprecate RepoNameForReference
2025-03-04 14:00:55 +01:00
6f46cd2f4b cli/registry/client: deprecate RepoNameForReference
This function was added in 02719bdbb5, and
used newDefaultRepositoryEndpoint to get repository info for the given
image-reference.

newDefaultRepositoryEndpoint uses registry.ParseRepositoryInfo under the
hood, but the only information used from the result was the Name field,
which is set using `reference.TrimNamed(name)`. The possible error returned
was based on the domain-name of the image, and only checked for the domain
to not start, or end with a hyphen ("-").

This patch removes the use of RepoNameForReference, deprecates it, and
inlines the code used by it.

There are no known consumers of this function, so we can consider removing
it in the first possible release after this (which can be a minor release).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-03 15:48:06 +01:00
1a165fd535 cli/registry/client: un-export ErrHTTPProto
This type was added in 02719bdbb5, but was
never used outside of the package itself. This patch un-exports it.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-03 15:32:58 +01:00
293bbb44a0 cli/registry/client: remove unused PutManifestOptions
This type was added in 02719bdbb5, but was
never used;

    git rev-parse --verify HEAD
    02719bdbb5

    git grep 'PutManifestOptions'
    cli/registry/client/client.go:// PutManifestOptions is the data sent to push a manifest
    cli/registry/client/client.go:type PutManifestOptions struct {

This patch removes it, because it's not used.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-03 15:22:42 +01:00
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