Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

De-duplicate run args passed to bazel image targets. #2184

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions container/incremental_load.sh.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,16 @@ function read_variables() {
# This is not executed if the single argument --norun is passed or
# no run_statements are generated (in which case, 'run' is 'False').
if [[ "%{run}" == "True" ]]; then
# When 'bazel run' is called, it expects that the args specified in the BUILD
# file are not known to the run command and will prepend them to all other
# arguments.
#
# However, we have already baked those commands into the image, because users
# expect that 'args' in the case of an image target will be included in the
# image. This templated script de-duplicates the args specified in the BUILD
# file by skipping the number of args already included in the image command.
shift "%{run_num_args}"

docker_args=()
container_args=()

Expand Down
1 change: 1 addition & 0 deletions container/layer_tools.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ def incremental_load(
"%{docker_flags}": " ".join(toolchain_info.docker_flags),
"%{docker_tool_path}": docker_path(toolchain_info),
"%{load_statements}": "\n".join(load_statements),
"%{run_num_args}": str(len(ctx.attr.args)),
"%{run_statement}": run_statement,
"%{run_tag}": run_tag,
"%{run}": str(run),
Expand Down