@rophy123/helmtest 2.0.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +67 -1
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -19,4 +19,70 @@ Differences with [Stono/helmtest](https://github.com/Stono/helm-test):
19
19
 
20
20
  ## Getting Started
21
21
 
22
- See [example](../../tree/example) as an example helm chart project which includes unit tests.
22
+ ### Running helmtest as npm module
23
+
24
+ Install helmtest:
25
+
26
+ ```bash
27
+ npm install @rophy123/helmtest
28
+ ```
29
+
30
+ To use helmtest in your code:
31
+
32
+ ```javascript
33
+ const helmtest = require('@rophy123/helmtest');
34
+
35
+ // Run `helm template` under working directory
36
+ helmtest.renderTemplate()
37
+ .then(results => {
38
+ // results are JS objects converted from result YAML.
39
+ // '[{"apiVesrion":"v1","kind":"ServiceAccount","metadata":...
40
+ console.log(JSON.stringify(results));
41
+ });
42
+ ```
43
+
44
+ The results object can be used to verify details. For example, in jest:
45
+
46
+ ```javascript
47
+ const helmtest = require('@rophy123/helmtest');
48
+
49
+ test('exmapleChart should render 4 resources', async () => {
50
+ const result = await helmtest.renderTemplate();
51
+ expect(result.length).toBe(4);
52
+ });
53
+ ```
54
+
55
+ See [API Spec](#api-spec) for the options of `helmtest.renderTemplate()`.
56
+
57
+ ### Running helmtest as CLI
58
+
59
+ Install [jest](https://jestjs.io/) along with helmtest globally:
60
+
61
+ ```bash
62
+ npm install -g @rophy123/helmtest jest
63
+ ```
64
+
65
+ ...and then you can write unit tests under `tests/` dir of your chart project without the need for package.json
66
+
67
+ A docker image [rophy/helmtest](https://hub.docker.com/r/rophy/helmtest) is avilable which includes everything to run up unit tests.
68
+
69
+ See [example](../../tree/example) as an example helm chart project on how to use docker image and write unit tests.
70
+
71
+ ## API Spec
72
+
73
+ helmtest currently only expose one method: `helmtest.renderTemplate(options)`.
74
+
75
+ `options` is a object with option names, descriptions and defaults as below:
76
+
77
+ | Option | Description | Default |
78
+ | -------------------- | ----------------------------------------------------------------------------------- | ------------------------------------------------- |
79
+ | chartDir | Path to chart, the `CHART` arg in helm CLI: `helm template [NAME] [CHART] [flags]`. | `'.'` |
80
+ | releaseName | Release name, the `NAME` arg in helm CLI: `helm template [NAME] [CHART] [flags]`. | `'release-name'` |
81
+ | values | A map of chart values to set. | `{}` |
82
+ | valuesFiles | A list of paths to additional values.yaml. | `[]` |
83
+ | extraHelmArgs | A list of extra args to pass to helm CLI, e.g. `--timeout=5s` | `[]` |
84
+ | helmBinary | Path to helm binary. | `process.env.HELM_BINARY || 'helm'` |
85
+ | loadYaml | if `false`, will return rendered template as raw string instead of js object. | `true` |
86
+ | kubeconformEnabled | if `true`, will pass rendered template to kubeconform CLI to validate schema. | `process.env.KUBECONFORM_ENABLED || false` |
87
+ | kubeconformBinary | Path to kubeconform binary. | `process.env.KUBECONFORM_BINARY || 'kubeconform'` |
88
+ | kubeconformExtraArgs | A list of extra args to pass to kubeconform CLI. | `process.env.KUBECONFORM_ARGS || []` |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rophy123/helmtest",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "Write unit tests against your helm charts using JavaScript.",
5
5
  "main": "index.js",
6
6
  "bin": {