@@ -26,30 +26,30 @@ CMD = """\
26
26
27
27
readonly st=$(rlocation {st_path})
28
28
readonly yq=$(rlocation {yq_path})
29
- readonly image=$(rlocation {image_path})
30
29
31
30
# When the image points to a folder, we can read the index.json file inside
32
- if [[ -d "$image" ]]; then
33
- readonly DIGEST=$("$yq" eval '.manifests[0].digest | sub(":"; "-")' "${{image}}/index.json")
31
+ if [[ -d "{image_path}" ]]; then
32
+ readonly DIGEST=$("$yq" eval '.manifests[0].digest | sub(":"; "-")' "{image_path}/index.json")
33
+ exec "$st" test {fixed_args} --default-image-tag "registry.structure_test.oci.local/image:$DIGEST" $@
34
+ else
35
+ exec "$st" test {fixed_args} $@
34
36
fi
35
-
36
- exec "$st" test {fixed_args} $@
37
37
"""
38
38
39
39
def _structure_test_impl (ctx ):
40
40
fixed_args = ["--driver" , ctx .attr .driver ]
41
41
test_bin = ctx .toolchains ["@container_structure_test//bazel:structure_test_toolchain_type" ].st_info .binary
42
42
yq_bin = ctx .toolchains ["@aspect_bazel_lib//lib:yq_toolchain_type" ].yqinfo .bin
43
43
44
- image_path = to_rlocation_path ( ctx , ctx .file .image )
44
+ image_path = ctx .file .image . short_path
45
45
# Prefer to use a tarball if we are given one, as it works with more 'driver' types.
46
46
if image_path .endswith (".tar" ):
47
- fixed_args .extend (["--image" , "$(rlocation %s)" % image_path ])
47
+ fixed_args .extend (["--image" , image_path ])
48
48
else :
49
49
# https://github.com/GoogleContainerTools/container-structure-test/blob/5e347b66fcd06325e3caac75ef7dc999f1a9b614/cmd/container-structure-test/app/cmd/test.go#L110
50
50
if ctx .attr .driver != "docker" :
51
51
fail ("when the 'driver' attribute is not 'docker', then the image must be a .tar file" )
52
- fixed_args .extend (["--image-from-oci-layout" , "$(rlocation %s)" % image_path ])
52
+ fixed_args .extend (["--image-from-oci-layout" , image_path ])
53
53
fixed_args .extend (["--default-image-tag" , "registry.structure_test.oci.local/image:$DIGEST" ])
54
54
55
55
for arg in ctx .files .configs :
0 commit comments