Skip to content

Commit

Permalink
Fix container bundle pusher broken by #591 (#651)
Browse files Browse the repository at this point in the history
* Fix container bundle pusher broken by #591

This fixes #609. Also added end to end test to verify bundle pusher and
regular pusher upload legal images.

* Fix typo & formatting

* Address review comments
  • Loading branch information
smukherj1 authored Jan 11, 2019
1 parent fe16305 commit e4b4fc2
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 4 deletions.
8 changes: 4 additions & 4 deletions contrib/push-all.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@ def _impl(ctx):
ctx.actions.expand_template(
template = ctx.file._tag_tpl,
substitutions = {
"%{stamp}": stamp_arg,
"%{tag}": ctx.expand_make_variables("tag", tag, {}),
"%{image}": "%s %s %s %s" % (
"%{args}": "%s --name=%s %s %s %s %s %s" % (
"--oci" if ctx.attr.format == "OCI" else "",
ctx.expand_make_variables("tag", tag, {}),
stamp_arg,
legacy_base_arg,
config_arg,
digest_arg,
layer_arg,
),
"%{format}": "--oci" if ctx.attr.format == "OCI" else "",
"%{container_pusher}": _get_runfile_path(ctx, ctx.executable._pusher),
},
output = out,
Expand Down
15 changes: 15 additions & 0 deletions testing/e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,22 @@ function test_container_push_with_stamp() {
docker stop -t 0 $cid
}

function test_container_push_all() {
cd "${ROOT}"
clear_docker
cid=$(docker run --rm -d -p 5000:5000 --name registry registry:2)
# Use bundle push to push three images to the local registry.
bazel run tests/docker:test_docker_push_three_images_bundle
# Pull the three images we just pushed to ensure uploaded manifests
# are valid according to docker.
EXPECT_CONTAINS "$(docker pull localhost:5000/image0:latest)" "Downloaded newer image"
EXPECT_CONTAINS "$(docker pull localhost:5000/image1:latest)" "Downloaded newer image"
EXPECT_CONTAINS "$(docker pull localhost:5000/image2:latest)" "Downloaded newer image"
docker stop -t 0 $cid
}

test_container_push_with_stamp
test_container_push_all
test_container_push_with_auth
test_container_pull_with_auth
test_top_level
Expand Down
16 changes: 16 additions & 0 deletions tests/docker/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ load(
"@bazel_tools//tools/build_rules:test_rules.bzl",
"file_test",
)
load("//container:bundle.bzl", "container_bundle")
load("//contrib:push-all.bzl", docker_push_all = "docker_push")

container_test(
name = "structure_test",
Expand Down Expand Up @@ -300,3 +302,17 @@ container_test(
configs = ["//tests/docker/configs:stripped_directory_name.yaml"],
image = ":stripped_directory_name",
)

container_bundle(
name = "three_images_bundle",
images = {
"localhost:5000/image0:latest": "//testdata:base_with_entrypoint",
"localhost:5000/image1:latest": "//testdata:link_with_files_base",
"localhost:5000/image2:latest": "//testdata:with_double_env",
},
)

docker_push_all(
name = "test_docker_push_three_images_bundle",
bundle = ":three_images_bundle",
)

0 comments on commit e4b4fc2

Please sign in to comment.