Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: return correct extension metadata #611

Merged
merged 1 commit into from
Jun 4, 2024
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
2 changes: 1 addition & 1 deletion e2e/smoke/MODULE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ oci.pull(
"linux/arm64",
],
)
use_repo(oci, "distroless_base")
use_repo(oci, "distroless_base", "distroless_base_linux_amd64", "distroless_base_linux_arm64")
13 changes: 9 additions & 4 deletions oci/extensions.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,21 @@ def _oci_extension(module_ctx):
)

if mod.is_root:
if module_ctx.is_dev_dependency(pull):
root_direct_dev_deps.append(pull.name)
else:
root_direct_deps.append(pull.name)
deps = root_direct_dev_deps if module_ctx.is_dev_dependency(pull) else root_direct_deps
deps.append(pull.name)
for platform in pull.platforms:
deps.append("_".join([pull.name] + platform.split("/")))
Comment on lines +47 to +48
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, what would be the reason to include these deps here? rules_oci v1.7 works without me including them via use_repo and I am curious, why I am suddenly asked to include them via the bazel mod tidy command.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding is it resolves an error like

WARNING: /builds/app/MODULE.bazel:38:20: The module extension oci defined in @rules_oci//oci:extensions.bzl reported incorrect imports of repositories via use_repo():
Not imported, but reported as direct dependencies by the extension (may cause the build to fail):
    java_base_debug_nonroot_debian12, java_base_nonroot_debian12
Imported, but reported as indirect dependencies by the extension:
    java_base_debug_nonroot_debian12_linux_amd64, java_base_debug_nonroot_debian12_linux_arm64_v8, java_base_nonroot_debian12_linux_amd64, java_base_nonroot_debian12_linux_arm64_v8
Fix the use_repo calls by running 'bazel mod tidy'.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bazel mod tidy could support something like absolutely neccesary repos vs could have if build requires it kind of use_repo calls.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but this what we have to do for now, if we want to avoid that annoying warning message. @fmeum probably has better ideas for this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like @thesayyn's idea of something similar to a root_module_optional_deps attribute that silences the warning without also adding use_repo arguments. Could you file an issue for this if you think it would be useful?


for toolchains in mod.tags.toolchains:
if toolchains.name != "oci" and not mod.is_root:
fail("""\
Only the root module may override the default name for the oci toolchains.
This prevents conflicting registrations in the global namespace of external repos.
""")
if mod.is_root:
deps = root_direct_dev_deps if module_ctx.is_dev_dependency(toolchains) else root_direct_deps
deps.append("%s_crane_toolchains" % toolchains.name)
deps.append("%s_regctl_toolchains" % toolchains.name)

oci_register_toolchains(toolchains.name, register = False)

Expand Down
Loading