Skip to content

Commit

Permalink
Handle multiple extension calls correctly
Browse files Browse the repository at this point in the history
The generated repository name currently doesn't encode any other option
so we can only register a single toolchain for now.

Use more elaborate logic:
- Only allow registering a toolchain in the root module
- Only allow specifying a single toolchain and fail otherwise
  • Loading branch information
mering committed Jan 7, 2025
1 parent bd01252 commit a39ce9d
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions helm/extensions.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,23 @@ exports_files(glob(["**"]))
"""

def _helm_impl(ctx):
module = ctx.modules[0]
toolchain_options = module.tags.toolchain
if len(module.tags.options) > 0:
if module.is_root:
for module in ctx.modules:
if not module.is_root:
continue
if module.is_root and len(module.tags.options) > 0:
# TODO Use deprecation tag when available: https://github.com/bazelbuild/bazel/issues/24843
print("helm.options() is deprecated. Use helm.toolchain() instead.") # buildifier: disable=print
toolchain_options += module.tags.options
version = toolchain_options[0].version
helm_url_templates = toolchain_options[0].helm_url_templates
plugins = toolchain_options[0].plugins
print("helm.options() is deprecated. Use helm.toolchain() instead.") # # buildifier: disable=print
toolchain_options = module.tags.toolchain + module.tags.options
if len(toolchain_options) > 1:
fail("Only a single helm toolchain is supported for now.")
if len(toolchain_options) == 1:
toolchain_option = toolchain_options[0]
version = toolchain_option.version
helm_url_templates = toolchain_option.helm_url_templates
plugins = toolchain_option.plugins

_register_toolchains(version, helm_url_templates, plugins)
_register_go_yaml()
_register_toolchains(version, helm_url_templates, plugins)
_register_go_yaml()

def _register_toolchains(version, helm_url_templates, plugins):
if not version in HELM_VERSIONS:
Expand Down

0 comments on commit a39ce9d

Please sign in to comment.