Helm support is in alpha stage
Pants has good support for the most common operations for managing Helm charts sources. However there may be use cases not covered yet.
Please share feedback for what you need to use Pants with your Helm charts by either [opening a GitHub issue](🔗) or [joining our Slack](🔗)!
# Initial setup
First, activate the relevant backend in `
If you have more than one Helm chart in the same repository, organise them such that each of them lives in a separate folder with the chart definition file (`
Chart.yaml`) at their root. The Helm backend is capable of auto-detecting the root folder of your Helm charts taking the chart definition file `
Chart.yaml` as the reference for that root.
## Adding `
Helm charts are identified by the presence of a `
Chart.yaml` or `
Chart.yml` file, which contains relevant metadata about the chart like its name, version, dependencies, etc. To get started quickly you can create a simple `
Chart.yaml` file in your sources folder:
You can use the `
helm create` command to create an initial skeleton for your chart but be sure you have properly configured your source root patterns (as shown in the previous section) since the `
helm create` command will create a folder name with the name of your chart and place the sources inside.
Then run [`
./pants tailor ::`](🔗) to generate `
BUILD` files. This will scan your source repository in search of `
Chart.yaml` or `
Chart.yml` files and create a `
helm_chart` target for each of them.
## Basic operations
The given setup is enough to now do some common operations on our Helm chart source code.
The Helm backend has an implementation of the Pants' `
lint` goal which hooks it with the `
helm lint` command:
The linting command is non-strict by default. If you want to enforce strict linting it can be either done globally in the `
pants.toml` file, or in a per-chart target basis, using one of the two following ways:
Likewise, in a similar way you could enable strict linting globally and then choose to disable it in a per-target basis. Run `
./pants help helm` or `
./pants help helm_chart` for more information.
You can set the field `
skip_lint=True` on each `
helm_chart` target to avoid linting it.
Packing helm charts is supported out of the box via the Pants' `
package` goal. The final package will be saved as a `
.tgz` file under the `
dist` folder at your source root.
The final output folder can customised using the `
output_path` field in the `
helm_chart` target. Run `
./pants help helm_chart` for more information.
# Helm Unit tests
The Helm backend supports running Helm unit tests via the [Helm `
unittest` plugin](🔗). To run unit tests follow the instructions on how to use that plugin and then create a `
BUILD` file in the same folder where your tests live with the following target:
With the test files in places, you can now run `
./pants test ::` and Pants will execute each of your tests individually:
Pants can cancel tests that take too long, which is useful to prevent tests from hanging indefinitely.
To add a timeout, set the `
timeout` field to an integer value of seconds, like this:
When you set `
timeout` on the `
helm_unittest_tests` target generator, the same timeout will apply to every generated `
helm_unittest_test` target. Instead, you can use the `
You can also set a default value and a maximum value in `
If a target sets its `
timeout` higher than `
[test].timeout_maximum`, Pants will use the value in `
Use the option `
./pants test --no-timeouts` to temporarily disable timeouts, e.g. when debugging.
# Publishing Helm charts
Pants only supports publishing Helm charts to OCI registries, a feature that was made generally available in Helm 3.8.
The publishing is done with Pants' `
publish` goal but first you will need to tell Pants what are the possible destination registries where to upload your charts.
## Configuring OCI registries
In a similar way as the `
docker_image` target, a `
helm_chart` target takes an optional `
registries` field whose value is a list of registry endpoints (prefixed by the `
The chart published from that given target will be uploaded to the OCI registry specified.
If you have several charts that have to be published into the same registries, you can add them to your `
pants.toml` file and then reference them by using their alias prefixed by a `
You can also designate one or more registries as default and then charts that have no explicit `
registries` field will use those default registries.
## Setting a repository name
When publishing charts into an OCI registry, you most likely will be interested on separating them from other kind of OCI assets (i.e. container images). For doing so you can set a `
repository` field in the `
helm_chart` target so the chart artifact will be uploaded to the given path:
With the previous setting, your chart would be published to your default registry under the `
charts` folder like in `
You can also set a default global repository in `
pants.toml` as in the following example:
# Managing Chart Dependencies
Helm charts can depend on other charts, whether first-party charts defined in the same repo, or third-party charts published in a registry. Pants uses this dependency information to know when work needs to be re-run.
To benefit from Pants dependency management and inference in your Helm charts, you will need to use `
apiVersion: v2` in your `
Pants will automatically infer dependencies from the `
For example, given two charts `
foo` and `
bar` and a dependency between them:
Then, running `
./pants dependencies`on `
bar` will list `
foo` as a dependency:
## Explicitly provided dependencies in `
If you prefer, you can let your BUILD files be the "source of truth" for dependencies, instead of specifying them in `
In this case, the `
./pants dependencies` command will show the same result and, in addition, Pants will modify its copy of `
Chart.yaml` before using it, so that it includes `
foo` in its dependency list. Note that Pants will not modify the original copy in your source tree, only the copy it uses in the sandboxed execution environment.
## Third party chart artifacts
Third party charts are provided to Pants using the `
Third party artifacts are resolved using `
helm pull`. Other charts can reference them in the same way as first-party charts (either in the `
Chart.yaml` or in the `
When adding third party artifacts, the `
artifact` and `
version` fields are mandatory, in addition to one _origin_ from which to download the actual archive. There are two different origins supported: _classic Helm repositories_ and _OCI registries_.
For **classic repositories**, provide with the full URL to the location of the chart archive, excluding the archive file itself:
For **OCI registries**, you must provide with the URL to the registry in the `
registry` field and an optional `
repository` field with the path inside that registry.