@@ -5,7 +5,7 @@ load("@aspect_bazel_lib//lib:windows_utils.bzl", "create_windows_native_launcher
55
66_attrs = {
77 "image" : attr .label (
8- allow_single_file = True ,
8+ allow_files = True ,
99 doc = "Label of an oci_image or oci_tarball target." ,
1010 ),
1111 "configs" : attr .label_list (allow_files = True , mandatory = True ),
@@ -48,7 +48,25 @@ def _structure_test_impl(ctx):
4848 test_bin = ctx .toolchains ["@container_structure_test//bazel:structure_test_toolchain_type" ].st_info .binary
4949 jq_bin = ctx .toolchains ["@aspect_bazel_lib//lib:jq_toolchain_type" ].jqinfo .bin
5050
51- image_path = to_rlocation_path (ctx , ctx .file .image )
51+ default_info = ctx .attr .image [DefaultInfo ] if DefaultInfo in ctx .attr .image else None
52+ output_group_info = ctx .attr .image [OutputGroupInfo ] if OutputGroupInfo in ctx .attr .image else None
53+ image = None
54+ image_files = []
55+ if output_group_info :
56+ for group_name in ["oci_layout" , "oci_tarball" ]:
57+ if group_name in output_group_info :
58+ image_files = output_group_info [group_name ].to_list ()
59+ if len (image_files ) != 1 :
60+ fail ("the 'image' attribute contains the '%s' output group but it does not have exactly one file" % group_name )
61+ image = image_files [0 ]
62+ break
63+ if not image and default_info and len (default_info .files .to_list ()) == 1 :
64+ image_files = default_info .files .to_list ()
65+ image = image_files [0 ]
66+ if not image :
67+ fail ("the 'image' attribute must be a target that produces exactly one file or contain either the 'oci_layout' or 'oci_tarball' output groups" )
68+
69+ image_path = to_rlocation_path (ctx , image )
5270
5371 # Prefer to use a tarball if we are given one, as it works with more 'driver' types.
5472 if image_path .endswith (".tar" ):
@@ -81,7 +99,7 @@ def _structure_test_impl(ctx):
8199 is_windows = ctx .target_platform_has_constraint (ctx .attr ._windows_constraint [platform_common .ConstraintValueInfo ])
82100 launcher = create_windows_native_launcher_script (ctx , bash_launcher ) if is_windows else bash_launcher
83101 runfiles = ctx .runfiles (
84- files = ctx . files . image + ctx .files .configs + [
102+ files = image_files + ctx .files .configs + [
85103 bash_launcher ,
86104 test_bin ,
87105 jq_bin ,
0 commit comments