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

Add extension to allow bazelmod style handling of dependencies #124

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Ongy
Copy link

@Ongy Ongy commented Dec 20, 2024

No description provided.

Copy link
Contributor

@mering mering left a comment

Choose a reason for hiding this comment

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

Thanks for taking the time to proposing this upstream!

version = repository.version,
)

helm_import = module_extension(
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider merging this with the module extension above by introducing the repository tag_class there.

This way, from a user perspective, this is could then be used like

helm = use_extension("@rules_helm//helm:extensions.bzl", "helm")
helm.options(...)
helm.repository(...)
helm.repository(...)

Comment on lines +152 to +154
"url": attr.string(
doc = "The url where the chart can be directly downloaded.",
),
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems to be a different use case not using a helm repository but downloading a chart directly. Consider making this a separate tag class (for example calling it chart instead of repository).

def _helm_import_impl(module_ctx):
for mod in module_ctx.modules:
for repository in mod.tags.repository:
helm_import_repository(
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider de-duplicating this based on repository. For this to work out well, you could generate the "name" based on the repository URL similar to rules_go. Then you could use a dict to check if this repository was already registered.

Imagine some (transitive) dependency also wants to import the same helm repository. With the current version, the same repository would get imported twice which is undesirable and can lead to conflicts.

If this is out of scope, a common practice is to only allow using this in the root module (if mod.is_root) and otherwise printing a warning that this is ignored. This makes migration to a more elaborate approach later a lot easier.

Comment on lines +139 to +141
"name": attr.string(
doc = "Name for the import dependency",
),
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider generating the name based on the repository instead of allowing the user to specify this explicitly (see other comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants