Skip to content

Commit 899af81

Browse files
authored
feat: expose the digest as a filegroup (#542)
1 parent 360df7a commit 899af81

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

e2e/pull/wksp/BUILD.bazel

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
load("@rules_oci//oci:defs.bzl", "oci_image", "oci_push")
2+
load("@aspect_bazel_lib//lib:diff_test.bzl", "diff_test")
3+
load("@bazel_skylib//rules:write_file.bzl", "write_file")
24

35
oci_image(
46
name = "empty",
@@ -12,3 +14,17 @@ oci_push(
1214
remote_tags = ["latest"],
1315
repository = "localhost/empty_image",
1416
)
17+
18+
write_file(
19+
name = "want_digest_contents",
20+
out = "want_image_digest.json",
21+
content = [
22+
"sha256:2d4595bbc0fabeb1489b1071f56c26f44a2f495afaa9386ad7d24e7b3d8dfd3e",
23+
],
24+
)
25+
26+
diff_test(
27+
name = "check_they_match",
28+
file1 = "want_digest_contents",
29+
file2 = "@empty_image//:digest",
30+
)

e2e/pull/wksp/MODULE.bazel

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
bazel_dep(name = "rules_oci", version = "0.0.0", dev_dependency = True)
44
bazel_dep(name = "platforms", version = "0.0.7")
5+
bazel_dep(name = "bazel_skylib", version = "1.5.0")
6+
bazel_dep(name = "aspect_bazel_lib", version = "2.1.0")
57

68
local_path_override(
79
module_name = "rules_oci",

oci/private/pull.bzl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,12 @@ oci_pull = repository_rule(
303303
)
304304

305305
_MULTI_PLATFORM_IMAGE_ALIAS_TMPL = """\
306+
filegroup(
307+
name = "digest",
308+
srcs = ["digest.txt"],
309+
visibility = ["//visibility:public"],
310+
)
311+
306312
alias(
307313
name = "{target_name}",
308314
actual = select(
@@ -314,6 +320,12 @@ alias(
314320
"""
315321

316322
_SINGLE_PLATFORM_IMAGE_ALIAS_TMPL = """\
323+
filegroup(
324+
name = "digest",
325+
srcs = ["digest.txt"],
326+
visibility = ["//visibility:public"],
327+
)
328+
317329
alias(
318330
name = "{target_name}",
319331
actual = "@{original}//:{original}",
@@ -333,6 +345,7 @@ def _oci_alias_impl(rctx):
333345
available_platforms = []
334346

335347
manifest, _, digest = downloader.download_manifest(rctx.attr.identifier, "mf.json")
348+
rctx.file("digest.txt", digest)
336349

337350
if rctx.attr.platforms:
338351
if manifest["mediaType"] in _SUPPORTED_MEDIA_TYPES["index"]:

0 commit comments

Comments
 (0)