Skip to content

Add helm_binary() rule for proper executable access to helm toolchain #231

@iDiogenes

Description

@iDiogenes

When upgrading from rules_helm 0.13.0 to 0.20.1, we found that the @helm//:helm target created by helm.host_tools() is defined as a plain source file:

Generated BUILD.bazel in @helm repository

exports_files(["helm"])

This causes integration issues with tools that expect proper executable targets with standard Bazel providers. While the symlink technically works, it's not optimal for toolchain-aware contexts.

The current approach for accessing the helm binary leaves users with unclear options:

  • @helm//:helm - Plain file, non-executable target
  • @helm_linux_amd64//:helm - Platform-specific, requires manual platform detection
  • @rules_helm//helm:current_toolchain - Toolchain resolver, but not an executable target

Proposed Solution

Add a helm_binary() rule that provides proper executable access to the helm toolchain:

Example usage in a BUILD.bazel file

  load("@rules_helm//helm:defs.bzl", "helm_binary")

  helm_binary(
      name = "helm",
  )

This would:

  1. Leverage the existing toolchain infrastructure
  2. Provide proper DefaultInfo and FilesToRunProvider
  3. Handle platform resolution automatically via toolchains
  4. Be extensible for future enhancements (env vars, flags, etc.)
  5. Follow patterns established by other mature rule sets (rules_go, rules_rust)

Implementation Approach

I'd like to contribute this fix if you're open to it. My plan would be:

  1. Add helm/private/helm_binary.bzl implementing the rule
  2. Export it from helm/defs.bzl
  3. Update documentation with migration guidance from helm.host_tools()
  4. Add tests for the new rule

The implementation would be straightforward - resolve the toolchain and expose the binary with proper providers.

Questions before I proceed:

  • Does this approach align with the rules_helm roadmap?
  • Should helm.host_tools() be deprecated in favor of this?
  • Any specific requirements for the rule API or behavior?

Context

  • rules_helm: 0.20.1
  • Bazel: 8.x (Bzlmod)
  • Use case: Integrating helm CLI into development environments (bazel_env.bzl)

Looking forward to your feedback!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions