Skip to content

Commit 9a32fc2

Browse files
aignasalexeagle
authored andcommitted
feat: expose the digest as a filegroup (#542)
1 parent 7bece45 commit 9a32fc2

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

e2e/assertion/wksp/BUILD.bazel

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

35
oci_image(
@@ -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+
)

oci/private/pull.bzl

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

311311
_MULTI_PLATFORM_IMAGE_ALIAS_TMPL = """\
312+
filegroup(
313+
name = "digest",
314+
srcs = ["digest.txt"],
315+
visibility = ["//visibility:public"],
316+
)
317+
312318
alias(
313319
name = "{target_name}",
314320
actual = select(
@@ -320,6 +326,12 @@ alias(
320326
"""
321327

322328
_SINGLE_PLATFORM_IMAGE_ALIAS_TMPL = """\
329+
filegroup(
330+
name = "digest",
331+
srcs = ["digest.txt"],
332+
visibility = ["//visibility:public"],
333+
)
334+
323335
alias(
324336
name = "{target_name}",
325337
actual = "@{original}//:{original}",
@@ -339,6 +351,7 @@ def _oci_alias_impl(rctx):
339351
available_platforms = []
340352

341353
manifest, _, digest = downloader.download_manifest(rctx.attr.identifier, "mf.json")
354+
rctx.file("digest.txt", digest)
342355

343356
if rctx.attr.platforms:
344357
if manifest["mediaType"] in _SUPPORTED_MEDIA_TYPES["index"]:

0 commit comments

Comments
 (0)