diff --git a/cli/command/cli.go b/cli/command/cli.go index f3012abe3e..832a0161c4 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 @@ -86,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 { @@ -157,14 +149,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 @@ -601,7 +585,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)) -}