Skip to content

Commit 8985d21

Browse files
mortenmjalexeagle
andauthored
Return extension_metadata from oci.pull() (#580)
Co-authored-by: Alex Eagle <[email protected]>
1 parent 89ed979 commit 8985d21

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

oci/extensions.bzl

+14
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ Overriding the default is only permitted in the root module.
2929

3030
def _oci_extension(module_ctx):
3131
registrations = {}
32+
root_direct_deps = []
33+
root_direct_dev_deps = []
3234
for mod in module_ctx.modules:
3335
for pull in mod.tags.pull:
3436
oci_pull(
@@ -41,6 +43,11 @@ def _oci_extension(module_ctx):
4143
config = pull.config,
4244
is_bzlmod = True,
4345
)
46+
if mod.is_root:
47+
if module_ctx.is_dev_dependency(pull):
48+
root_direct_dev_deps.append(pull.name)
49+
else:
50+
root_direct_deps.append(pull.name)
4451
for toolchains in mod.tags.toolchains:
4552
if toolchains.name != "oci" and not mod.is_root:
4653
fail("""\
@@ -61,6 +68,13 @@ def _oci_extension(module_ctx):
6168
selected = versions[0]
6269
oci_register_toolchains(name, crane_version = selected[0], zot_version = selected[1], register = False)
6370

71+
# Allow use_repo calls to be automatically managed by `bazel mod tidy`. See
72+
# https://docs.google.com/document/d/1dj8SN5L6nwhNOufNqjBhYkk5f-BJI_FPYWKxlB3GAmA/edit#heading=h.5mcn15i0e1ch
73+
return module_ctx.extension_metadata(
74+
root_module_direct_deps = root_direct_deps,
75+
root_module_direct_dev_deps = root_direct_dev_deps,
76+
)
77+
6478
oci = module_extension(
6579
implementation = _oci_extension,
6680
tag_classes = {

0 commit comments

Comments
 (0)