Skip to content
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
4 changes: 2 additions & 2 deletions MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module(
version = "0.0.0",
)

# To run yq
# To run jq
bazel_dep(name = "aspect_bazel_lib", version = "1.28.0")
bazel_dep(name = "bazel_skylib", version = "1.4.1")
bazel_dep(name = "platforms", version = "0.0.5")
Expand All @@ -17,4 +17,4 @@ use_repo(ext, "structure_test_toolchains")
register_toolchains("@structure_test_toolchains//:all")

# 0.5.4 is the first version with bzlmod support
bazel_dep(name = "stardoc", version = "0.5.4", repo_name = "io_bazel_stardoc")
bazel_dep(name = "stardoc", version = "0.5.4", repo_name = "io_bazel_stardoc", dev_dependency = True)
10 changes: 5 additions & 5 deletions bazel/container_structure_test.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ CMD_HEAD = [

CMD = """\
readonly st=$(rlocation {st_path})
readonly yq=$(rlocation {yq_path})
readonly jq=$(rlocation {jq_path})
readonly image=$(rlocation {image_path})

# When the image points to a folder, we can read the index.json file inside
if [[ -d "$image" ]]; then
readonly DIGEST=$("$yq" eval '.manifests[0].digest | sub(":"; "-")' "$image/index.json")
readonly DIGEST=$("$jq" -r '.manifests[0].digest | sub(":"; "-")' "$image/index.json")
exec "$st" test --driver {driver} {fixed_args} --default-image-tag "registry.structure_test.oci.local/image:$DIGEST" $@
else
exec "$st" test --driver {driver} {fixed_args} $@
Expand All @@ -42,7 +42,7 @@ fi
def _structure_test_impl(ctx):
fixed_args = []
test_bin = ctx.toolchains["@container_structure_test//bazel:structure_test_toolchain_type"].st_info.binary
yq_bin = ctx.toolchains["@aspect_bazel_lib//lib:yq_toolchain_type"].yqinfo.bin
jq_bin = ctx.toolchains["@aspect_bazel_lib//lib:jq_toolchain_type"].jqinfo.bin

image_path = to_rlocation_path(ctx, ctx.file.image)

Expand All @@ -64,7 +64,7 @@ def _structure_test_impl(ctx):
bash_launcher,
content = "\n".join(CMD_HEAD) + CMD.format(
st_path = to_rlocation_path(ctx, test_bin),
yq_path = to_rlocation_path(ctx, yq_bin),
jq_path = to_rlocation_path(ctx, jq_bin),
driver = ctx.attr.driver,
image_path = image_path,
fixed_args = " ".join(fixed_args),
Expand All @@ -78,7 +78,7 @@ def _structure_test_impl(ctx):
files = ctx.files.image + ctx.files.configs + [
bash_launcher,
test_bin,
yq_bin,
jq_bin,
],
).merge(ctx.attr._runfiles.default_runfiles)

Expand Down
3 changes: 0 additions & 3 deletions bazel/test/WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,3 @@ load("@container_structure_test//:repositories.bzl", "container_structure_test_r

container_structure_test_register_toolchain(name = "cst")

load("@aspect_bazel_lib//lib:repositories.bzl", "register_yq_toolchains")

register_yq_toolchains()
2 changes: 1 addition & 1 deletion defs.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ https://github.com/GoogleContainerTools/container-structure-test#running-file-te
""",
test = True,
toolchains = [
"@aspect_bazel_lib//lib:yq_toolchain_type",
"@aspect_bazel_lib//lib:jq_toolchain_type",
"@bazel_tools//tools/sh:toolchain_type",
"@container_structure_test//bazel:structure_test_toolchain_type",
],
Expand Down
4 changes: 3 additions & 1 deletion repositories.bzl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Repository rules for fetching pre-built container-test binaries"""

load("@aspect_bazel_lib//lib:repositories.bzl", "register_jq_toolchains")
load("//bazel:toolchains_repo.bzl", "PLATFORMS", "toolchains_repo")

# TODO(alexeagle): automate updates when new releases
Expand Down Expand Up @@ -68,6 +68,8 @@ def container_structure_test_register_toolchain(name, register = True):

st_toolchain_name = "structure_test_toolchains"

register_jq_toolchains(register = register)

for platform in PLATFORMS.keys():
structure_test_repositories(
name = "{name}_st_{platform}".format(name = name, platform = platform),
Expand Down