Skip to content

Commit

Permalink
Update contributing docs for Helm 3 (hashicorp#516)
Browse files Browse the repository at this point in the history
  • Loading branch information
lkysow authored Jun 29, 2020
1 parent bb4b92c commit a2bf66f
Showing 1 changed file with 22 additions and 11 deletions.
33 changes: 22 additions & 11 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,20 @@ The acceptance tests require a Kubernetes cluster with a configured `kubectl`.
brew install kubernetes-helm
```

### Helm 2/3
These tests will work with both Helm 2 and 3 if run through `bats`, e.g. `bats ./test/unit`. If copying the
test command and running yourself, e.g.
```sh
helm template \
-s templates/sync-catalog-deployment.yaml \
--set 'syncCatalog.enabled=true' \
--set 'syncCatalog.toConsul=false' \
.
```
It's expected that the version of `helm` in your path is Helm 3.

In our CI/CD the tests are run against both Helm 2 and Helm 3.

### Running The Tests
To run the unit tests:

Expand Down Expand Up @@ -99,7 +113,7 @@ Here are some examples of common test patterns:
@test "ui/Service: no type by default" {
cd `chart_dir`
local actual=$(helm template \
-x templates/ui-service.yaml \
-s templates/ui-service.yaml \
. | tee /dev/stderr |
yq -r '.spec.type' | tee /dev/stderr)
[ "${actual}" = "null" ]
Expand All @@ -115,7 +129,7 @@ Here are some examples of common test patterns:
@test "ui/Service: specified type" {
cd `chart_dir`
local actual=$(helm template \
-x templates/ui-service.yaml \
-s templates/ui-service.yaml \
--set 'ui.service.type=LoadBalancer' \
. | tee /dev/stderr |
yq -r '.spec.type' | tee /dev/stderr)
Expand All @@ -130,15 +144,15 @@ Here are some examples of common test patterns:
@test "syncCatalog/Deployment: to-k8s only" {
cd `chart_dir`
local actual=$(helm template \
-x templates/sync-catalog-deployment.yaml \
-s templates/sync-catalog-deployment.yaml \
--set 'syncCatalog.enabled=true' \
--set 'syncCatalog.toConsul=false' \
. | tee /dev/stderr |
yq '.spec.template.spec.containers[0].command | any(contains("-to-consul=false"))' | tee /dev/stderr)
[ "${actual}" = "true" ]
local actual=$(helm template \
-x templates/sync-catalog-deployment.yaml \
-s templates/sync-catalog-deployment.yaml \
--set 'syncCatalog.enabled=true' \
--set 'syncCatalog.toConsul=false' \
. | tee /dev/stderr |
Expand All @@ -155,12 +169,9 @@ Here are some examples of common test patterns:
```
@test "syncCatalog/Deployment: disabled by default" {
cd `chart_dir`
local actual=$(helm template \
-x templates/sync-catalog-deployment.yaml \
. | tee /dev/stderr |
yq 'length > 0' | tee /dev/stderr)
[ "${actual}" = "false" ]
assert_empty helm template \
-s templates/sync-catalog-deployment.yaml \
.
}
```
Here we are check the length of the command output to see if the anything is rendered.
This style can easily be switched to check that a file is rendered instead.
Here we are using the `assert_empty` helper command that works with both Helm 2 and 3.

0 comments on commit a2bf66f

Please sign in to comment.