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

Add option to push images sequentially in push-all #1658

Merged
merged 1 commit into from
Nov 3, 2020
Merged
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
11 changes: 10 additions & 1 deletion contrib/push-all.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,15 @@ def _impl(ctx):
ctx.actions.expand_template(
template = ctx.file._all_tpl,
substitutions = {
"%{push_statements}": "\n".join([
"%{async_push_statements}": "\n".join([
"async \"%s\"" % _get_runfile_path(ctx, command)
for command in scripts
]),
"%{push_statements}": "\n".join([
"\"%s\"" % _get_runfile_path(ctx, command)
for command in scripts
]),
"%{sequential}": "true" if ctx.attr.sequential else "",
},
output = ctx.outputs.executable,
is_executable = True,
Expand Down Expand Up @@ -100,6 +105,10 @@ container_push = rule(
],
doc = "The form to push: Docker or OCI.",
),
"sequential": attr.bool(
default = False,
doc = "If true, push images sequentially.",
),
"_all_tpl": attr.label(
default = Label("//contrib:push-all.sh.tpl"),
allow_single_file = True,
Expand Down
16 changes: 11 additions & 5 deletions contrib/push-all.sh.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,17 @@ function async() {
PIDS+=($!)
}

%{push_statements}

# Wait for all of the subprocesses, failing the script if any of them failed.
if [ "${#PIDS[@]}" != 0 ]; then
SEQUENTIAL="%{sequential}"
if [ -z "${SEQUENTIAL}" ]; then
%{async_push_statements}
# Wait for all of the subprocesses, failing the script if any of them failed.
if [ "${#PIDS[@]}" != 0 ]; then
for pid in ${PIDS[@]}; do
wait ${pid}
wait ${pid}
done
fi
else
%{push_statements}
fi