From 4362b921f8b087316c3df33e32b246504be15968 Mon Sep 17 00:00:00 2001 From: Tomasz Wojno Date: Fri, 14 Jul 2023 10:02:20 +0000 Subject: [PATCH] Use empty string as fallback value for undefined environment variables The current implementation of dockerfile_build rule looks up for environment variables value and uses `None` as fallback value. This causes to resolve into `--build-arg =None` build argument, which is seen as valid string. Instead, we should fallback to empty string for undefined environment variables, which resolves to `--build-arg =''` and is interpreted as empty value. --- contrib/dockerfile_build.bzl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/dockerfile_build.bzl b/contrib/dockerfile_build.bzl index fe66bebbc..2c18359c4 100644 --- a/contrib/dockerfile_build.bzl +++ b/contrib/dockerfile_build.bzl @@ -59,7 +59,7 @@ def _impl(repository_ctx): build_args.extend(["--build-arg", "%s=%s" % (pair[0], pair[1])]) if repository_ctx.attr.vars: for env_var in repository_ctx.attr.vars: - build_args.extend(["--build-arg", "%s=%s" % (env_var, repository_ctx.os.environ.get(env_var))]) + build_args.extend(["--build-arg", "%s=%s" % (env_var, repository_ctx.os.environ.get(env_var, ""))]) # The docker bulid command needs to run using the supplied Dockerfile # because it may refer to relative paths in its ADD, COPY and WORKDIR