From 592afa8c73937fff234df518bafdc0fd795b10ef Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 25 Sep 2025 17:40:33 +0200 Subject: [PATCH 1/3] cli/command: remove deprecated DockerCli.ContentTrustEnabled This function was used internally, but is no longer used. Users should check the value of the `DOCKER_CONTENT_TRUST` environment variable instead. This method was deprecated in 11d40488dd818aadbb4757ff57da040479b4e9a6, which was included in the 28.5.0 release, and has no known external users, so removing it for 29.0 Signed-off-by: Sebastiaan van Stijn --- cli/command/cli.go | 8 -------- 1 file changed, 8 deletions(-) diff --git a/cli/command/cli.go b/cli/command/cli.go index f3012abe3e..000a7f22e6 100644 --- a/cli/command/cli.go +++ b/cli/command/cli.go @@ -157,14 +157,6 @@ func (cli *DockerCli) ServerInfo() ServerInfo { return cli.serverInfo } -// ContentTrustEnabled returns whether content trust has been enabled by an -// environment variable. -// -// Deprecated: check the value of the DOCKER_CONTENT_TRUST environment variable to detect whether content-trust is enabled. -func (cli *DockerCli) ContentTrustEnabled() bool { - return cli.contentTrust -} - // BuildKitEnabled returns buildkit is enabled or not. func (cli *DockerCli) BuildKitEnabled() (bool, error) { // use DOCKER_BUILDKIT env var value if set and not empty From e25843bfb6a665976a9f317c45d71d2217fa0f47 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 25 Sep 2025 17:47:51 +0200 Subject: [PATCH 2/3] cli/command: remove deprecated WithContentTrustFromEnv, WithContentTrust These options were used internally as defaults for the constructor and only impact commands implemented in the CLI itself. They were deprecated in 40cdfc0d8133de2b168784d06aa5720fe0cd9c42, which was included in the 28.5.0 release, so removing it for 29.0 Signed-off-by: Sebastiaan van Stijn --- cli/command/cli.go | 2 -- cli/command/cli_options.go | 32 -------------------------------- cli/command/cli_options_test.go | 28 ---------------------------- 3 files changed, 62 deletions(-) delete mode 100644 cli/command/cli_options_test.go diff --git a/cli/command/cli.go b/cli/command/cli.go index 000a7f22e6..674e3879f2 100644 --- a/cli/command/cli.go +++ b/cli/command/cli.go @@ -67,7 +67,6 @@ type DockerCli struct { err *streams.Out client client.APIClient serverInfo ServerInfo - contentTrust bool contextStore store.Store currentContext string init sync.Once @@ -593,7 +592,6 @@ type ServerInfo struct { // environment. func NewDockerCli(ops ...CLIOption) (*DockerCli, error) { defaultOps := []CLIOption{ - withContentTrustFromEnv(), WithDefaultContextStoreConfig(), WithStandardStreams(), WithUserAgent(UserAgent()), diff --git a/cli/command/cli_options.go b/cli/command/cli_options.go index 4de7b2a8a0..f787956c5b 100644 --- a/cli/command/cli_options.go +++ b/cli/command/cli_options.go @@ -8,7 +8,6 @@ import ( "io" "net/http" "os" - "strconv" "strings" "github.com/docker/cli/cli/streams" @@ -76,37 +75,6 @@ func WithErrorStream(err io.Writer) 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 != "" { - if t, err := strconv.ParseBool(e); t || err != nil { - // treat any other value as true - cli.contentTrust = true - } - } - return nil - } -} - -// 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 - return nil - } -} - // WithDefaultContextStoreConfig configures the cli to use the default context store configuration. func WithDefaultContextStoreConfig() CLIOption { return func(cli *DockerCli) error { diff --git a/cli/command/cli_options_test.go b/cli/command/cli_options_test.go deleted file mode 100644 index 946a94df74..0000000000 --- a/cli/command/cli_options_test.go +++ /dev/null @@ -1,28 +0,0 @@ -package command - -import ( - "os" - "testing" - - "gotest.tools/v3/assert" -) - -func contentTrustEnabled(t *testing.T) bool { - t.Helper() - var cli DockerCli - assert.NilError(t, withContentTrustFromEnv()(&cli)) - return cli.contentTrust -} - -// NB: Do not t.Parallel() this test -- it messes with the process environment. -func TestWithContentTrustFromEnv(t *testing.T) { - const envvar = "DOCKER_CONTENT_TRUST" - t.Setenv(envvar, "true") - assert.Check(t, contentTrustEnabled(t)) - t.Setenv(envvar, "false") - assert.Check(t, !contentTrustEnabled(t)) - t.Setenv(envvar, "invalid") - assert.Check(t, contentTrustEnabled(t)) - os.Unsetenv(envvar) - assert.Check(t, !contentTrustEnabled(t)) -} From 782deffe83986e5eb13040f5df52cb0aa63b8c87 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 25 Sep 2025 17:51:09 +0200 Subject: [PATCH 3/3] cli/command: remove deprecated DockerCli.DefaultVersion This function was used internally, but is no longer used. This method was deprecated in 0270b2d6f764f4d564deba1ac504527bdcf65da1, which was included in the 28.5.0 release, and has no known external users, so removing it for 29.0 Signed-off-by: Sebastiaan van Stijn --- cli/command/cli.go | 7 ------- 1 file changed, 7 deletions(-) diff --git a/cli/command/cli.go b/cli/command/cli.go index 674e3879f2..832a0161c4 100644 --- a/cli/command/cli.go +++ b/cli/command/cli.go @@ -85,13 +85,6 @@ type DockerCli struct { enableGlobalMeter, enableGlobalTracer bool } -// DefaultVersion returns [client.MaxAPIVersion]. -// -// Deprecated: this function is no longer used and will be removed in the next release. -func (*DockerCli) DefaultVersion() string { - return client.MaxAPIVersion -} - // CurrentVersion returns the API version currently negotiated, or the default // version otherwise. func (cli *DockerCli) CurrentVersion() string {