@rophy123/helmtest 1.1.0 → 2.0.0
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.
- package/README.md +22 -0
- package/bin/helmtest +16 -1
- package/package.json +8 -3
- package/.dockerignore +0 -2
- package/Dockerfile +0 -28
package/README.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# helmtest
|
|
2
|
+
|
|
3
|
+
A npm module which enables writing unit tests with nodejs / Jest.
|
|
4
|
+
|
|
5
|
+
Heavily inspired by [Stono/helmtest](https://github.com/Stono/helm-test).
|
|
6
|
+
|
|
7
|
+
## Why not just use Stono/helmtest?
|
|
8
|
+
|
|
9
|
+
I originally wanted to update [Stono/helmtest](https://github.com/Stono/helm-test) to fit my needs,
|
|
10
|
+
but after attempting to customize it, I figured it's actually easier to rewrite one.
|
|
11
|
+
|
|
12
|
+
Differences with [Stono/helmtest](https://github.com/Stono/helm-test):
|
|
13
|
+
|
|
14
|
+
- Single js file for the core logic (lib/helmtest.js)
|
|
15
|
+
- Supports [kubeconform](https://github.com/yannh/kubeconform) instead of [kubeval](https://github.com/instrumenta/kubeval/)
|
|
16
|
+
- No Grunt and TypeScript
|
|
17
|
+
- Can be used as a npm library without assuming test framework and passing objects around global scope.
|
|
18
|
+
- Can also run independently as CLI. In this case [jest](https://jestjs.io/) is bundled instead of mocha/chai.
|
|
19
|
+
|
|
20
|
+
## Getting Started
|
|
21
|
+
|
|
22
|
+
See [example](../../tree/example) as an example helm chart project which includes unit tests.
|
package/bin/helmtest
CHANGED
|
@@ -1,7 +1,22 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
const jest = require('jest');
|
|
4
3
|
const path = require('path');
|
|
4
|
+
const helmtest = require('../lib/helmtest');
|
|
5
|
+
|
|
6
|
+
let jest;
|
|
7
|
+
|
|
8
|
+
try {
|
|
9
|
+
jest = require('jest');
|
|
10
|
+
} catch (err) {
|
|
11
|
+
if (err.code == 'MODULE_NOT_FOUND') {
|
|
12
|
+
console.error(`ERROR: ${err.message}`);
|
|
13
|
+
// eslint-disable-next-line max-len
|
|
14
|
+
console.error('jest is required when running helmtest as CLI. Install it by `npm install [-g] jest`');
|
|
15
|
+
process.exit(1);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
globalThis.helmtest = helmtest;
|
|
5
20
|
|
|
6
21
|
jest.run([
|
|
7
22
|
'--testMatch',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rophy123/helmtest",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Write unit tests against your helm charts using JavaScript.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -21,12 +21,17 @@
|
|
|
21
21
|
"homepage": "https://github.com/rophy/helmtest#readme",
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"debug": "^4.3.4",
|
|
24
|
-
"jest": "^29.5.0",
|
|
25
24
|
"js-yaml": "^4.1.0"
|
|
26
25
|
},
|
|
27
26
|
"devDependencies": {
|
|
28
27
|
"eslint": "^8.36.0",
|
|
29
|
-
"eslint-config-google": "^0.14.0"
|
|
28
|
+
"eslint-config-google": "^0.14.0",
|
|
29
|
+
"jest": "^29.5.0"
|
|
30
|
+
},
|
|
31
|
+
"peerDependenciesMeta": {
|
|
32
|
+
"jest": {
|
|
33
|
+
"optional": true
|
|
34
|
+
}
|
|
30
35
|
},
|
|
31
36
|
"engines": {
|
|
32
37
|
"node": ">=16.0.0"
|
package/.dockerignore
DELETED
package/Dockerfile
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
FROM node:16.19.1-bullseye-slim
|
|
2
|
-
|
|
3
|
-
RUN apt-get update && apt-get install -y curl git
|
|
4
|
-
|
|
5
|
-
RUN curl -sLo ./helm.tar.gz https://get.helm.sh/helm-v3.11.2-linux-amd64.tar.gz \
|
|
6
|
-
&& tar -zxvf helm.tar.gz linux-amd64/helm \
|
|
7
|
-
--strip-components 1 && mv ./helm /usr/local/bin/ \
|
|
8
|
-
&& rm ./helm.tar.gz
|
|
9
|
-
|
|
10
|
-
RUN curl -sLo ./helm.tar.gz https://get.helm.sh/helm-v3.11.2-linux-amd64.tar.gz \
|
|
11
|
-
&& tar -zxvf helm.tar.gz linux-amd64/helm \
|
|
12
|
-
--strip-components 1 && mv ./helm /usr/local/bin/ \
|
|
13
|
-
&& rm ./helm.tar.gz
|
|
14
|
-
|
|
15
|
-
RUN curl -sLo kubeconform.tar.gz https://github.com/yannh/kubeconform/releases/download/v0.6.1/kubeconform-linux-amd64.tar.gz \
|
|
16
|
-
&& tar -zxvf kubeconform.tar.gz kubeconform \
|
|
17
|
-
&& mv ./kubeconform /usr/local/bin/ \
|
|
18
|
-
&& rm kubeconform.tar.gz
|
|
19
|
-
|
|
20
|
-
ENV KUBERNETES_VERSION=1.22.9
|
|
21
|
-
RUN cd / && git clone --depth 1 --filter=blob:none --sparse https://github.com/yannh/kubernetes-json-schema \
|
|
22
|
-
&& cd kubernetes-json-schema \
|
|
23
|
-
&& git sparse-checkout set v${KUBERNETES_VERSION}-standalone-strict \
|
|
24
|
-
&& rm -rf ./.git
|
|
25
|
-
|
|
26
|
-
ENV KUBECONFORM_ENABLED=true KUBECONFORM_ARGS="-kubernetes-version ${KUBERNETES_VERSION} -schema-location /kubernetes-json-schema -strict"
|
|
27
|
-
ENV HELM_REGISTRY_CONFIG=/tmp/registry.json DOCKER_CONFIG=/tmp/config.json
|
|
28
|
-
RUN npm install -g @rophy123/helmtest
|