mirror of https://github.com/docker/cli.git
Handle empty DOCKER_BUILDKIT like unset
This fixes the cli erroring out if the variable is set to an empty
value.
```
$ export DOCKER_BUILDKIT=
$ docker version
DOCKER_BUILDKIT environment variable expects boolean value: strconv.ParseBool: parsing "": invalid syntax
```
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
(cherry picked from commit ff7f76af7a
)
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
This commit is contained in:
parent
f480fb1e37
commit
c648e0b065
|
@ -164,8 +164,8 @@ func (cli *DockerCli) ContentTrustEnabled() bool {
|
||||||
|
|
||||||
// BuildKitEnabled returns buildkit is enabled or not.
|
// BuildKitEnabled returns buildkit is enabled or not.
|
||||||
func (cli *DockerCli) BuildKitEnabled() (bool, error) {
|
func (cli *DockerCli) BuildKitEnabled() (bool, error) {
|
||||||
// use DOCKER_BUILDKIT env var value if set
|
// use DOCKER_BUILDKIT env var value if set and not empty
|
||||||
if v, ok := os.LookupEnv("DOCKER_BUILDKIT"); ok {
|
if v := os.Getenv("DOCKER_BUILDKIT"); v != "" {
|
||||||
enabled, err := strconv.ParseBool(v)
|
enabled, err := strconv.ParseBool(v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, errors.Wrap(err, "DOCKER_BUILDKIT environment variable expects boolean value")
|
return false, errors.Wrap(err, "DOCKER_BUILDKIT environment variable expects boolean value")
|
||||||
|
|
|
@ -44,9 +44,9 @@ func processBuilder(dockerCli command.Cli, cmd *cobra.Command, args, osargs []st
|
||||||
var buildKitDisabled, useBuilder, useAlias bool
|
var buildKitDisabled, useBuilder, useAlias bool
|
||||||
var envs []string
|
var envs []string
|
||||||
|
|
||||||
// check DOCKER_BUILDKIT env var is present and
|
// check DOCKER_BUILDKIT env var is not empty
|
||||||
// if not assume we want to use the builder component
|
// if it is assume we want to use the builder component
|
||||||
if v, ok := os.LookupEnv("DOCKER_BUILDKIT"); ok {
|
if v := os.Getenv("DOCKER_BUILDKIT"); v != "" {
|
||||||
enabled, err := strconv.ParseBool(v)
|
enabled, err := strconv.ParseBool(v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return args, osargs, nil, errors.Wrap(err, "DOCKER_BUILDKIT environment variable expects boolean value")
|
return args, osargs, nil, errors.Wrap(err, "DOCKER_BUILDKIT environment variable expects boolean value")
|
||||||
|
|
Loading…
Reference in New Issue