-
Notifications
You must be signed in to change notification settings - Fork 40
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
Bzlmod support #50
Bzlmod support #50
Conversation
Hey, it looks close, I'll take a look next week. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great! A few nits.
Those tests are now combined, I had to delete the WORKSPACE.bzlmod file in e2e/smoke because it seems that the dependencies of rules_distroless are managed by the MODULE.bzl, so with that WORKSPACE.bzlmod file it would complain that it could not find certain dependencies (e.g. rules_oci) |
# Get the package name with either bzlmod enabled or disabled | ||
package_name = rctx.attr.name.split("~")[-1] | ||
|
||
package_defs = [ | ||
'"""Generated by rules_distroless. DO NOT EDIT."""', | ||
"""load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")""", | ||
"", | ||
"", | ||
"# buildifier: disable=function-docstring", | ||
"def {}_packages():".format(rctx.attr.name), | ||
"def {}_packages():".format(package_name), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also had to get the last component of the path, as otherwise it would put ~ in the function name and then error: syntax error at '~': expected (
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
Hi there, I'm not sure if this is the best-practice way to implement bzlmod, but it does seem to work. Any feedback welcome. I've created a test for it in e2e/ so that the MODULE.bazel is different to the root one like the examples/ have; but I can move to examples/ if that would be better.