Chart Testing
ct
is the the tool for testing Helm charts.
It is meant to be used for linting and testing pull requests.
It automatically detects charts changed against the target branch.
Installation
Prerequisites
It is recommended to use the provided Docker image which can be found on Quay.
It comes with all necessary tools installed.
Binary Distribution
Download the release distribution for your OS from the Releases page:
https://github.com/helm/chart-testing/releases
Unpack the ct
binary, add it to your PATH, and you are good to go!
Docker Image
A Docker image is available at quay.io/helmpack/chart-testing
.
Usage
See documentation for individual commands:
Configuration
ct
is a command-line application.
All command-line flags can also be set via environment variables or config file.
Environment variables must be prefixed with CT_
. Underscores must be used instead of hyphens.
CLI flags, environment variables, and a config file can be mixed. The following order of precedence applies:
- CLI flags
- Environment variables
- Config file
Note that linting requires config file for yamllint and yamale.
If not specified, these files are search in the current directory, $HOME/.ct
, and /etc/ct
, in that order.
Samples are provided in the etc folder.
Examples
The following example show various way of configuring the same thing:
CLI
ct install --remote upstream --chart-dirs stable,incubator --build-id pr-42
Environment Variables
export CT_REMOTE=upstream
export CT_CHART_DIRS=stable,incubator
export CT_BUILD_ID
ct install
Config File
config.yaml
:
remote: upstream
chart-dirs:
- stable
- incubator
build-id: pr-42
ct install --config config.yaml
ct
supports any format Viper can read, i. e. JSON, TOML, YAML, HCL, and Java properties files.
Building from Source
ct
is built using Go 1.11. Older versions may work but have not been tested.
build.sh
is used to build and release the tool. It uses Goreleaser under the covers.
Note: on MacOS you will need GNU Coreutils readlink
. You can install it with:
brew install coreutils
Then add gnubin
to your $PATH
, with:
echo 'export PATH="$(brew --prefix coreutils)/libexec/gnubin:$PATH"' >> ~/.bash_profile
bash --login
To use the build script:
$ ./build.sh -h
Usage: build.sh <options>
Build ct using Goreleaser.
-h, --help Display help
-d, --debug Display verbose output and run Goreleaser with --debug
-r, --release Create a release using Goreleaser. This includes the creation
of a GitHub release and building and pushing the Docker image.
If this flag is not specified, Goreleaser is run with --snapshot
Releasing
CircleCI creates releases automatically when a new tag is pushed. Tags are created using tag.sh
.
$ ./tag.sh -h
Usage: tag.sh <options>
Create and push a tag.
-h, --help Display help
-d, --debug Display verbose output
-r, --remote The name of the remote to push the tag to (default: upstream)
-f, --force Force an existing tag to be overwritten
-t, --tag The name of the tag to create
-s, --skip-push Skip pushing the tag