From 40cdfc0d8133de2b168784d06aa5720fe0cd9c42 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 25 Sep 2025 09:17:01 +0200 Subject: [PATCH] cli/command: deprecate WithContentTrustFromEnv, WithContentTrust These options were used internally as defaults for the constructor and only impact commands implemented in the CLI itself. Signed-off-by: Sebastiaan van Stijn --- cli/command/cli.go | 2 +- cli/command/cli_options.go | 13 +++++++++++-- cli/command/cli_options_test.go | 2 +- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/cli/command/cli.go b/cli/command/cli.go index 026d0807a9e4..f4b339acd830 100644 --- a/cli/command/cli.go +++ b/cli/command/cli.go @@ -597,7 +597,7 @@ type ServerInfo struct { // environment. func NewDockerCli(ops ...CLIOption) (*DockerCli, error) { defaultOps := []CLIOption{ - WithContentTrustFromEnv(), + withContentTrustFromEnv(), WithDefaultContextStoreConfig(), WithStandardStreams(), WithUserAgent(UserAgent()), diff --git a/cli/command/cli_options.go b/cli/command/cli_options.go index 87f8a2cc7d7c..4de7b2a8a0ad 100644 --- a/cli/command/cli_options.go +++ b/cli/command/cli_options.go @@ -76,8 +76,8 @@ func WithErrorStream(err io.Writer) CLIOption { } } -// WithContentTrustFromEnv enables content trust on a cli from environment variable DOCKER_CONTENT_TRUST value. -func WithContentTrustFromEnv() CLIOption { +// withContentTrustFromEnv enables content trust on a cli from environment variable DOCKER_CONTENT_TRUST value. +func withContentTrustFromEnv() CLIOption { return func(cli *DockerCli) error { cli.contentTrust = false if e := os.Getenv("DOCKER_CONTENT_TRUST"); e != "" { @@ -90,7 +90,16 @@ func WithContentTrustFromEnv() CLIOption { } } +// WithContentTrustFromEnv enables content trust on a cli from environment variable DOCKER_CONTENT_TRUST value. +// +// Deprecated: this option is no longer used, and will be removed in the next release. +func WithContentTrustFromEnv() CLIOption { + return withContentTrustFromEnv() +} + // WithContentTrust enables content trust on a cli. +// +// Deprecated: this option is no longer used, and will be removed in the next release. func WithContentTrust(enabled bool) CLIOption { return func(cli *DockerCli) error { cli.contentTrust = enabled diff --git a/cli/command/cli_options_test.go b/cli/command/cli_options_test.go index 45ac1d8a5773..946a94df7468 100644 --- a/cli/command/cli_options_test.go +++ b/cli/command/cli_options_test.go @@ -10,7 +10,7 @@ import ( func contentTrustEnabled(t *testing.T) bool { t.Helper() var cli DockerCli - assert.NilError(t, WithContentTrustFromEnv()(&cli)) + assert.NilError(t, withContentTrustFromEnv()(&cli)) return cli.contentTrust }