Merge pull request #4216 from vvoland/buildkit-empty

Handle empty DOCKER_BUILDKIT like unset
This commit is contained in:
Sebastiaan van Stijn 2023-04-19 20:28:36 +02:00 committed by GitHub
commit d4f2609ce8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View File

@ -162,8 +162,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")

View File

@ -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")