Bazel rules for Helm.

Rules

Providers

Functions

Aspects

Repository Rules

chart_file

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

chart_file(name, api_version, app_version, app_version_file, chart_name, description, icon, type,
           version, version_file)

Create a Helm chart file.

ATTRIBUTES

NameDescriptionTypeMandatoryDefault
nameA unique name for this target.Namerequired
api_versionThe Helm API versionStringoptional"v2"
app_versionThe version number of the application being deployed.Stringoptional"1.16.0"
app_version_fileA file containing the version number of the application being deployed.LabeloptionalNone
chart_nameThe name of the chartStringoptional""
descriptionA descritpion of the chart.Stringoptional"A Helm chart for Kubernetes by Bazel."
iconA URL to an SVG or PNG image to be used as an icon.Stringoptional""
typeThe chart type.Stringoptional"application"
versionThe chart version.Stringoptional"0.1.0"
version_fileA file containing the chart version.LabeloptionalNone

helm_import

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

helm_import(name, chart, version)

A rule that allows pre-packaged Helm charts to be used within Bazel.

ATTRIBUTES

NameDescriptionTypeMandatoryDefault
nameA unique name for this target.Namerequired
chartA Helm chart's .tgz file.LabeloptionalNone
versionThe version fo the helm chartStringoptional""

helm_install

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

helm_install(name, data, helm_opts, install_name, opts, package, values)

Produce an executable for performing a helm install operation.

ATTRIBUTES

NameDescriptionTypeMandatoryDefault
nameA unique name for this target.Namerequired
dataAdditional data to pass to helm install.List of labelsoptional[]
helm_optsAdditional arguments to pass to helm during install.List of stringsoptional[]
install_nameThe name to use for the helm install command. The target name will be used if unset.Stringoptional""
optsAdditional arguments to pass to helm install.List of stringsoptional[]
packageThe helm package to install.Labelrequired
valuesValues files to pass to helm install --values.List of labelsoptional[]

helm_lint_test

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

helm_lint_test(name, chart, opts, substitutions, values)

A rule for performing helm lint on a helm package

ATTRIBUTES

NameDescriptionTypeMandatoryDefault
nameA unique name for this target.Namerequired
chartThe helm package to run linting on.Labelrequired
optsAdditional arguments to pass to helm lint.List of stringsoptional[]
substitutionsA dictionary of substitutions passed to `helm lint --set flag.Dictionary: String -> Stringoptional{}
valuesA list of files passed to `helm lint --values flag.List of labelsoptional[]

helm_oci_digest

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

helm_oci_digest(name, chart)

Compute the OCI manifest digest for a Helm chart at build time.

This rule constructs the OCI manifest that helm push (Helm v4) would create and computes its sha256 digest. The .tgz file's mtime is used for the creation annotation, formatted in UTC to match the push side.

The digest file contains a single line: sha256:<hex>.

ATTRIBUTES

NameDescriptionTypeMandatoryDefault
nameA unique name for this target.Namerequired
chartA helm_chart target providing HelmPackageInfo.Labelrequired

helm_package

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

helm_package(name, deps, chart, chart_json, crds, files, images, opts, schema, stamp, substitutions,
             templates, values, values_json)

Rules for creating Helm chart packages.

ATTRIBUTES

NameDescriptionTypeMandatoryDefault
nameA unique name for this target.Namerequired
depsOther helm packages this package depends on.List of labelsoptional[]
chartThe Chart.yaml file of the helm chartLabeloptionalNone
chart_jsonThe Chart.yaml file of the helm chart as a json objectStringoptional""
crdsAll Custom Resource Definitions associated with the current helm chart. E.g., the ./crds directoryList of labelsoptional[]
filesFiles accessed in templates via the .Files apiList of labelsoptional[]
imagesA list of oci_push or image_push targets.List of labelsoptional[]
optsAdditional arguments to pass to helm package commands.List of stringsoptional[]
schemaThe values.schema.json file for the current package.LabeloptionalNone
stampWhether to encode build information into the helm actions. Possible values:

- stamp = 1: Always stamp the build information into the helm actions, even in --nostamp builds. This setting should be avoided, since it potentially kills remote caching for the target and any downstream actions that depend on it.

- stamp = 0: Always replace build information by constant values. This gives good build result caching.

- stamp = -1: Embedding of build information is controlled by the --[no]stamp flag.

Stamped targets are not rebuilt unless their dependencies change.
Integeroptional-1
substitutionsA dictionary of substitutions to apply to the values.yaml file.Dictionary: String -> Stringoptional{}
templatesAll templates associated with the current helm chart. E.g., the ./templates directoryList of labelsoptional[]
valuesThe values.yaml file for the current package.LabeloptionalNone
values_jsonThe values.yaml file for the current package as a json object.Stringoptional""

helm_plugin

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

helm_plugin(name, data, plugin_name, yaml)

Define a helm plugin.

ATTRIBUTES

NameDescriptionTypeMandatoryDefault
nameA unique name for this target.Namerequired
dataAdditional files associated with the plugin.List of labelsoptional[]
plugin_nameAn explicit name for the plugin. If unset, name will be used.Stringoptional""
yamlThe yaml file representing the pluginLabelrequired

helm_push

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

helm_push(name, env, include_images, login_url, opts, package, push_cmd, registry_url)

Produce an executable for performing a helm push to a registry.

Before performing helm push the executable produced will conditionally perform helm registry login if the following environment variables are defined:

  • HELM_REGISTRY_USERNAME: The value of --username.
  • HELM_REGISTRY_PASSWORD/HELM_REGISTRY_PASSWORD_FILE: The value of --password or a file containing the --password value.

ATTRIBUTES

NameDescriptionTypeMandatoryDefault
nameA unique name for this target.Namerequired
envEnvironment variables to set when running this target.Dictionary: String -> Stringoptional{}
include_imagesIf True, images depended on by package will be pushed as well.BooleanoptionalFalse
login_urlThe URL of the registry to use for helm login. E.g. my.registry.ioStringoptional""
optsAdditional arguments to pass to helm commands.List of stringsoptional[]
packageThe helm package to push to the registry.Labelrequired
push_cmdAn alternative command to push for publishing the helm chart. E.g. cm-pushStringoptional""
registry_urlThe registry URL at which to push the helm chart to. E.g. oci://my.registry.io/chart-nameStringrequired

helm_push_images

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

helm_push_images(name, env, package)

Produce an executable for pushing all oci images used by a helm chart.

ATTRIBUTES

NameDescriptionTypeMandatoryDefault
nameA unique name for this target.Namerequired
envEnvironment variables to set when running this target.Dictionary: String -> Stringoptional{}
packageThe helm package to upload images from.Labelrequired

helm_push_registry

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

helm_push_registry(name, env, include_images, login_url, opts, package, push_cmd, registry_url)

Produce an executable for performing a helm push to a registry.

Before performing helm push the executable produced will conditionally perform helm registry login if the following environment variables are defined:

  • HELM_REGISTRY_USERNAME: The value of --username.
  • HELM_REGISTRY_PASSWORD/HELM_REGISTRY_PASSWORD_FILE: The value of --password or a file containing the --password value.

ATTRIBUTES

NameDescriptionTypeMandatoryDefault
nameA unique name for this target.Namerequired
envEnvironment variables to set when running this target.Dictionary: String -> Stringoptional{}
include_imagesIf True, images depended on by package will be pushed as well.BooleanoptionalFalse
login_urlThe URL of the registry to use for helm login. E.g. my.registry.ioStringoptional""
optsAdditional arguments to pass to helm commands.List of stringsoptional[]
packageThe helm package to push to the registry.Labelrequired
push_cmdAn alternative command to push for publishing the helm chart. E.g. cm-pushStringoptional""
registry_urlThe registry URL at which to push the helm chart to. E.g. oci://my.registry.io/chart-nameStringrequired

helm_template

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

helm_template(name, out, chart, opts, values)

A rule for rendering helm chart templates to a file.

ATTRIBUTES

NameDescriptionTypeMandatoryDefault
nameA unique name for this target.Namerequired
outThe output file to write the output from helm template.Label; nonconfigurableoptionalNone
chartThe helm package to resolve charts for.Labelrequired
optsAdditional arguments to pass to helm template.List of stringsoptional[]
valuesValues files to pass to helm template --values.List of labelsoptional[]

helm_template_test

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

helm_template_test(name, chart, installer, opts, template_patterns, values)

A test rule for rendering helm chart templates.

ATTRIBUTES

NameDescriptionTypeMandatoryDefault
nameA unique name for this target.Namerequired
chartThe helm package to resolve templates for. Mutually exclusive with installer.Labelrequired
installerThe helm_install/helm_upgrade target to resolve templates for. Mutually exclusive with chart.LabeloptionalNone
optsAdditional arguments to pass to helm template.List of stringsoptional[]
template_patternsA mapping of template paths to regex patterns required to match.Dictionary: String -> List of stringsoptional{}
valuesValues files to pass to helm template --values.List of labelsoptional[]

helm_toolchain

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

helm_toolchain(name, helm, plugins)

A helm toolchain.

ATTRIBUTES

NameDescriptionTypeMandatoryDefault
nameA unique name for this target.Namerequired
helmA helm binaryLabelrequired
pluginsAdditional plugins to make available to helm.List of labelsoptional[]

helm_uninstall

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

helm_uninstall(name, data, helm_opts, install_name, opts)

Produce an executable for performing a helm uninstall operation.

ATTRIBUTES

NameDescriptionTypeMandatoryDefault
nameA unique name for this target.Namerequired
dataAdditional data to pass to helm uninstall.List of labelsoptional[]
helm_optsAdditional arguments to pass to helm during install.List of stringsoptional[]
install_nameThe name to use for the helm install command. The target name will be used if unset.Stringoptional""
optsAdditional arguments to pass to helm uninstall.List of stringsoptional[]

helm_upgrade

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

helm_upgrade(name, data, helm_opts, install_name, opts, package, values)

Produce an executable for performing a helm upgrade operation.

ATTRIBUTES

NameDescriptionTypeMandatoryDefault
nameA unique name for this target.Namerequired
dataAdditional data to pass to helm upgrade.List of labelsoptional[]
helm_optsAdditional arguments to pass to helm during upgrade.List of stringsoptional[]
install_nameThe name to use for the helm upgrade command. The target name will be used if unset.Stringoptional""
optsAdditional arguments to pass to helm upgrade.List of stringsoptional[]
packageThe helm package to upgrade.Labelrequired
valuesValues files to pass to helm upgrade --values.List of labelsoptional[]

HelmOCIDigestInfo

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

HelmOCIDigestInfo(digest)

OCI manifest digest for a Helm chart, computed at build time.

FIELDS

NameDescription
digestFile: Text file containing the OCI manifest digest (sha256:...)

HelmPackageInfo

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

HelmPackageInfo(chart, images, metadata)

A provider for helm packages

FIELDS

NameDescription
chartFile: The result of helm package
imageslist[Target]: A list of @rules_oci//oci:defs.bzl%oci_push or @rules_img//img:push.bzl%image_push targets
metadataFile: A json encoded file containing metadata about the helm chart

chart_content

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

chart_content(name, api_version, description, type, version, app_version, icon)

A convenience wrapper for defining Chart.yaml files with helm_package.chart_json.

PARAMETERS

NameDescriptionDefault Value
nameThe name of the chartnone
api_versionThe Helm API version"v2"
descriptionA descritpion of the chart."A Helm chart for Kubernetes by Bazel."
typeThe chart type."application"
versionThe chart version."0.1.0"
app_versionThe version number of the application being deployed."1.16.0"
iconA URL to an SVG or PNG image to be used as an icon.None

RETURNS

str: A json encoded string which represents Chart.yaml contents.

helm_chart

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

helm_chart(*, name, chart, chart_json, crds, values, values_json, substitutions, templates, schema,
           files, images, deps, install_name, registry_url, login_url, push_cmd, helm_opts,
           install_opts, package_opts, push_opts, upgrade_opts, uninstall_opts, data, stamp, **kwargs)

Rules for producing a helm package and some convenience targets.

targetrulecondition
{name}helm_packageNone
{name}.push_imageshelm_push_imagesNone
{name}.oci_digesthelm_oci_digestNone
{name}.push_registryhelm_push (include_images = False)registry_url is defined.
{name}.pushhelm_push (include_images = True)registry_url is defined.
{name}.installhelm_installNone
{name}.uninstallhelm_uninstallNone
{name}.upgradehelm_upgradeNone

PARAMETERS

NameDescriptionDefault Value
nameThe name of the helm_package target.none
chartThe path to the chart directory. Defaults to Chart.yaml.None
chart_jsonThe json encoded contents of Chart.yaml.None
crdsA list of crd files to include in the package.None
valuesThe path to the values file. Defaults to values.yaml.None
values_jsonThe json encoded contents of values.yaml.None
substitutionsA dictionary of substitutions to apply to values.yaml.{}
templatesA list of template files to include in the package.None
schemaA JSON Schema file for values. Defaults to values.schema.json.None
filesFiles accessed in templates via the .Files api.[]
imagesA list of oci_push or image_push targets[]
depsA list of helm package dependencies.None
install_nameThe helm install name to use. name will be used if unset.None
registry_urlThe registry url for the helm chart. {name}.push_registry is only defined when a value is passed here.None
login_urlThe registry url to log into for publishing helm charts.None
push_cmdAn alternative command to push for publishing helm charts.None
helm_optsAdditional options to pass to helm.[]
install_optsAdditional options to pass to helm install.[]
package_optsAdditional options to pass to helm package.[]
push_optsAdditional options to pass to helm push.[]
upgrade_optsAdditional options to pass to helm upgrade.[]
uninstall_optsAdditional options to pass to helm uninstall.[]
dataAdditional runtime data to pass to the helm install, upgrade, and uninstall targets.[]
stampWhether to encode build information into the helm chart.None
kwargsAdditional keyword arguments for helm_package.none

helm_lint_aspect

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

helm_lint_aspect()

An aspect for running helm lint on helm package targets

ASPECT ATTRIBUTES

ATTRIBUTES

helm_import_repository

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

helm_import_repository(name, chart_name, repository, sha256, url, version)

A rule for fetching external Helm charts from an arbitrary URL or repository.

ATTRIBUTES

NameDescriptionTypeMandatoryDefault
nameA unique name for this repository.Namerequired
chart_nameChart name to import. Must be set if repository is specifiedStringoptional""
repositoryChart repository url where to locate the requested chart. Mutually exclusive with url.Stringoptional""
sha256The expected SHA-256 hash of the chart imported.Stringoptional""
urlThe url where a chart can be directly downloaded. Mutually exclusive with chart_name, repository, and versionStringoptional""
versionSpecify a version constraint for the chart version to use. Must be set if repository is specified.Stringoptional""