Skip to content

Commit 8212f6e

Browse files
authored
refactor: remove yq dependency (#379)
1 parent 21ed454 commit 8212f6e

File tree

5 files changed

+11
-12
lines changed

5 files changed

+11
-12
lines changed

MODULE.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ module(
66
version = "0.0.0",
77
)
88

9-
# To run yq
9+
# To run jq
1010
bazel_dep(name = "aspect_bazel_lib", version = "1.28.0")
1111
bazel_dep(name = "bazel_skylib", version = "1.4.1")
1212
bazel_dep(name = "platforms", version = "0.0.5")
@@ -17,4 +17,4 @@ use_repo(ext, "structure_test_toolchains")
1717
register_toolchains("@structure_test_toolchains//:all")
1818

1919
# 0.5.4 is the first version with bzlmod support
20-
bazel_dep(name = "stardoc", version = "0.5.4", repo_name = "io_bazel_stardoc")
20+
bazel_dep(name = "stardoc", version = "0.5.4", repo_name = "io_bazel_stardoc", dev_dependency = True)

bazel/container_structure_test.bzl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ CMD_HEAD = [
2727

2828
CMD = """\
2929
readonly st=$(rlocation {st_path})
30-
readonly yq=$(rlocation {yq_path})
30+
readonly jq=$(rlocation {jq_path})
3131
readonly image=$(rlocation {image_path})
3232
3333
# When the image points to a folder, we can read the index.json file inside
3434
if [[ -d "$image" ]]; then
35-
readonly DIGEST=$("$yq" eval '.manifests[0].digest | sub(":"; "-")' "$image/index.json")
35+
readonly DIGEST=$("$jq" -r '.manifests[0].digest | sub(":"; "-")' "$image/index.json")
3636
exec "$st" test --driver {driver} {fixed_args} --default-image-tag "registry.structure_test.oci.local/image:$DIGEST" $@
3737
else
3838
exec "$st" test --driver {driver} {fixed_args} $@
@@ -42,7 +42,7 @@ fi
4242
def _structure_test_impl(ctx):
4343
fixed_args = []
4444
test_bin = ctx.toolchains["@container_structure_test//bazel:structure_test_toolchain_type"].st_info.binary
45-
yq_bin = ctx.toolchains["@aspect_bazel_lib//lib:yq_toolchain_type"].yqinfo.bin
45+
jq_bin = ctx.toolchains["@aspect_bazel_lib//lib:jq_toolchain_type"].jqinfo.bin
4646

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

@@ -64,7 +64,7 @@ def _structure_test_impl(ctx):
6464
bash_launcher,
6565
content = "\n".join(CMD_HEAD) + CMD.format(
6666
st_path = to_rlocation_path(ctx, test_bin),
67-
yq_path = to_rlocation_path(ctx, yq_bin),
67+
jq_path = to_rlocation_path(ctx, jq_bin),
6868
driver = ctx.attr.driver,
6969
image_path = image_path,
7070
fixed_args = " ".join(fixed_args),
@@ -78,7 +78,7 @@ def _structure_test_impl(ctx):
7878
files = ctx.files.image + ctx.files.configs + [
7979
bash_launcher,
8080
test_bin,
81-
yq_bin,
81+
jq_bin,
8282
],
8383
).merge(ctx.attr._runfiles.default_runfiles)
8484

bazel/test/WORKSPACE.bazel

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,3 @@ load("@container_structure_test//:repositories.bzl", "container_structure_test_r
2525

2626
container_structure_test_register_toolchain(name = "cst")
2727

28-
load("@aspect_bazel_lib//lib:repositories.bzl", "register_yq_toolchains")
29-
30-
register_yq_toolchains()

defs.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ https://github.com/GoogleContainerTools/container-structure-test#running-file-te
2222
""",
2323
test = True,
2424
toolchains = [
25-
"@aspect_bazel_lib//lib:yq_toolchain_type",
25+
"@aspect_bazel_lib//lib:jq_toolchain_type",
2626
"@bazel_tools//tools/sh:toolchain_type",
2727
"@container_structure_test//bazel:structure_test_toolchain_type",
2828
],

repositories.bzl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
"""Repository rules for fetching pre-built container-test binaries"""
2-
2+
load("@aspect_bazel_lib//lib:repositories.bzl", "register_jq_toolchains")
33
load("//bazel:toolchains_repo.bzl", "PLATFORMS", "toolchains_repo")
44

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

6969
st_toolchain_name = "structure_test_toolchains"
7070

71+
register_jq_toolchains(register = register)
72+
7173
for platform in PLATFORMS.keys():
7274
structure_test_repositories(
7375
name = "{name}_st_{platform}".format(name = name, platform = platform),

0 commit comments

Comments
 (0)