diff --git a/helm/extensions.bzl b/helm/extensions.bzl index c184523..f031df8 100644 --- a/helm/extensions.bzl +++ b/helm/extensions.bzl @@ -193,6 +193,7 @@ def _helm_impl(module_ctx): helm_host_alias_repository( name = host_tools_attrs.name, toolchain_repo_prefix = "helm_toolchains__{}".format(host_tools_attrs.version), + version = host_tools_attrs.version, ) return module_ctx.extension_metadata( diff --git a/helm/private/repositories.bzl b/helm/private/repositories.bzl index d82a5d0..589c06c 100644 --- a/helm/private/repositories.bzl +++ b/helm/private/repositories.bzl @@ -1,5 +1,10 @@ """Helm dependencies""" +load( + "//helm/private:versions.bzl", + "DEFAULT_HELM_VERSION", +) + _HELM_TOOLCHAIN_BUILD_CONTENT = """\ load("@rules_helm//helm:helm_toolchain.bzl", "helm_toolchain") @@ -221,17 +226,23 @@ def _helm_host_alias_repository_impl(repository_ctx): ext = ".exe" if is_windows else "" repository_ctx.file("BUILD.bazel", """# @generated by @rules_helm//helm/private/repositories.bzl +load("@bazel_lib//lib:copy_file.bzl", "copy_file") + package(default_visibility = ["//visibility:public"]) -exports_files(["helm{ext}"]) -""".format( - ext = ext, - )) - repository_ctx.symlink("../{prefix}_{platform}_bin/helm{ext}".format( +copy_file( + name = "helm", + src = "@{prefix}_{platform}_bin//:helm_bin", + out = "helm-{version}{ext}", + is_executable = True, + allow_symlink = True, +) +""".format( prefix = repository_ctx.attr.toolchain_repo_prefix, platform = _platform(repository_ctx), ext = ext, - ), "helm{ext}".format(ext = ext)) + version = repository_ctx.attr.version, + )) helm_host_alias_repository = repository_rule( implementation = _helm_host_alias_repository_impl, @@ -243,6 +254,10 @@ helm_host_alias_repository = repository_rule( doc = "The name prefix for binary repos to symlink to. The host alias constructs the full repo name as {prefix}_{platform}_bin.", mandatory = True, ), + "version": attr.string( + doc = "The version of helm to use for host tools.", + default = DEFAULT_HELM_VERSION, + ), }, )