bazelbuild / rules_docker

Rules for building and handling Docker images with Bazel
Apache License 2.0
1.07k stars 692 forks source link

Use empty string as fallback value for undefined environment variables #2261

Open k0walik opened 1 year ago

k0walik commented 1 year ago

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

What is the current behavior?

The current implementation of dockerfile_build rule looks up for environment variables value and uses None as fallback value for undefined one. This causes to resolve into --build-arg <ENV_VAR>=None build argument, which is interpreted as valid, defined value.

What is the new behavior?

Instead, we should fallback to empty string for undefined environment variables, which resolves to --build-arg <ENV_VAR>='' and is interpreted as empty value. This would match the same output as produced in shell:

$ echo "NON_EXISTING_VARIABLE='${NON_EXISTING_VARIABLE}'"
NON_EXISTING_VARIABLE=''

Does this PR introduce a breaking change?

Other information