cli/flags: add EnvEnableTLS const for "DOCKER_TLS"

Add a const to allow documenting the environment variable in code. The location
of this const is a bit "unfortunate", due to CLI and Client-config to be spread
over the cli/config, cli/config/configfile, and docker/docker/client packages
(some options are for the client, others for the CLI), and some reorganizing
may be useful for easier consumption.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2023-06-28 13:56:24 +02:00
parent a26e6011f0
commit 1c1329fc7e
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
1 changed files with 13 additions and 2 deletions

View File

@ -14,6 +14,18 @@ import (
) )
const ( const (
// EnvEnableTLS is the name of the environment variable that can be used
// to enable TLS for client connections. When set to a non-empty value, TLS
// is enabled for API connections using TCP. For backward-compatibility, this
// environment-variable can only be used to enable TLS, not to disable.
//
// Note that TLS is always enabled implicitly if the "--tls-verify" option
// or "DOCKER_TLS_VERIFY" ([github.com/docker/docker/client.EnvTLSVerify])
// env var is set to, which could be to either enable or disable TLS certification
// validation. In both cases, TLS is enabled but, depending on the setting,
// with verification disabled.
EnvEnableTLS = "DOCKER_TLS"
// DefaultCaFile is the default filename for the CA pem file // DefaultCaFile is the default filename for the CA pem file
DefaultCaFile = "ca.pem" DefaultCaFile = "ca.pem"
// DefaultKeyFile is the default filename for the key pem file // DefaultKeyFile is the default filename for the key pem file
@ -39,8 +51,7 @@ Refer to https://docs.docker.com/go/formatting/ for more information about forma
var ( var (
dockerCertPath = os.Getenv(client.EnvOverrideCertPath) dockerCertPath = os.Getenv(client.EnvOverrideCertPath)
dockerTLSVerify = os.Getenv(client.EnvTLSVerify) != "" dockerTLSVerify = os.Getenv(client.EnvTLSVerify) != ""
// TODO(thaJeztah) the 'DOCKER_TLS' environment variable is not documented, and does not have a const. dockerTLS = os.Getenv(EnvEnableTLS) != ""
dockerTLS = os.Getenv("DOCKER_TLS") != ""
) )
// ClientOptions are the options used to configure the client cli. // ClientOptions are the options used to configure the client cli.