Skip to content

Commit eadcfd7

Browse files
authored
Merge pull request #191 from Labelbox/add-docker-to-pre-commit-hooks
Add containerized pre-commit hook
2 parents dd3d586 + c143157 commit eadcfd7

File tree

2 files changed

+89
-13
lines changed

2 files changed

+89
-13
lines changed

.pre-commit-hooks.yaml

+9
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,12 @@
1515
language: golang
1616
name: Helm Docs Built
1717
require_serial: true
18+
19+
- id: helm-docs-container
20+
args: []
21+
description: Uses the container image of 'helm-docs' to create documentation from the Helm chart's 'values.yaml' file, and inserts the result into a corresponding 'README.md' file.
22+
entry: jnorwood/helm-docs:latest
23+
files: (README\.md\.gotmpl|(Chart|requirements|values)\.yaml)$
24+
language: docker_image
25+
name: Helm Docs Container
26+
require_serial: true

README.md

+80-13
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,73 @@ pre-commit install-hooks
9999

100100
Future changes to your chart's `requirements.yaml`, `values.yaml`, `Chart.yaml`, or `README.md.gotmpl` files will cause an update to documentation when you commit.
101101

102+
There are several variants of `pre-commit` hooks to choose from depending on your use case.
103+
104+
#### `helm-docs` Uses `helm-docs` binary located in your `PATH`
105+
106+
```yaml
107+
---
108+
repos:
109+
- repo: https://github.com/jnorwood/helm-docs
110+
rev: ""
111+
hooks:
112+
- id: helm-docs
113+
args:
114+
# Make the tool search for charts only under the `charts` directory
115+
- --chart-search-root=charts
116+
117+
```
118+
119+
120+
#### `helm-docs-built` Uses `helm-docs` built from code in git
121+
122+
```yaml
123+
---
124+
repos:
125+
- repo: https://github.com/jnorwood/helm-docs
126+
rev: ""
127+
hooks:
128+
- id: helm-docs-built
129+
args:
130+
# Make the tool search for charts only under the `charts` directory
131+
- --chart-search-root=charts
132+
133+
```
134+
135+
136+
#### `helm-docs-container` Uses the container image of `helm-docs:latest`
137+
138+
```yaml
139+
---
140+
repos:
141+
- repo: https://github.com/jnorwood/helm-docs
142+
rev: ""
143+
hooks:
144+
- id: helm-docs-container
145+
args:
146+
# Make the tool search for charts only under the `charts` directory
147+
- --chart-search-root=charts
148+
149+
```
150+
151+
#### To pin the `helm-docs` container to a specific tag, follow the example below:
152+
153+
154+
```yaml
155+
---
156+
repos:
157+
- repo: https://github.com/jnorwood/helm-docs
158+
rev: ""
159+
hooks:
160+
- id: helm-docs-container
161+
entry: jnorwood/helm-docs:x.y.z
162+
args:
163+
# Make the tool search for charts only under the `charts` directory
164+
- --chart-search-root=charts
165+
166+
```
167+
168+
102169
### Running the binary directly
103170

104171
To run and generate documentation into READMEs for all helm charts within or recursively contained by a directory:
@@ -441,16 +508,16 @@ By default, this option is turned off:
441508

442509
```shell
443510
./helm-docs -c example-charts/helm-3
444-
INFO[2023-06-29T07:54:29-07:00] Found Chart directories [.]
445-
INFO[2023-06-29T07:54:29-07:00] Generating README Documentation for chart example-charts/helm-3
511+
INFO[2023-06-29T07:54:29-07:00] Found Chart directories [.]
512+
INFO[2023-06-29T07:54:29-07:00] Generating README Documentation for chart example-charts/helm-3
446513
```
447514

448515
but you can use the `-x` flag to turn it on:
449516

450517
```shell
451518
helm-docs -x -c example-charts/helm-3
452-
INFO[2023-06-29T07:55:12-07:00] Found Chart directories [.]
453-
WARN[2023-06-29T07:55:12-07:00] Error parsing information for chart ., skipping: values without documentation:
519+
INFO[2023-06-29T07:55:12-07:00] Found Chart directories [.]
520+
WARN[2023-06-29T07:55:12-07:00] Error parsing information for chart ., skipping: values without documentation:
454521
controller
455522
controller.name
456523
controller.image
@@ -469,29 +536,29 @@ The CLI also supports excluding fields by regexp using the `-z` argument
469536

470537
```shell
471538
helm-docs -x -z="controller.*" -c example-charts/helm-3
472-
INFO[2023-06-29T08:18:55-07:00] Found Chart directories [.]
473-
INFO[2023-06-29T08:18:55-07:00] Generating README Documentation for chart example-charts/helm-3
539+
INFO[2023-06-29T08:18:55-07:00] Found Chart directories [.]
540+
INFO[2023-06-29T08:18:55-07:00] Generating README Documentation for chart example-charts/helm-3
474541
```
475542

476-
Multiple regexp can be passed, as in the following example:
543+
Multiple regexp can be passed, as in the following example:
477544

478545
```shell
479546
helm-docs -x -z="controller.image.*" -z="controller.service.*" -z="controller.extraVolumes.*" -c example-charts/helm-3
480-
INFO[2023-06-29T08:21:04-07:00] Found Chart directories [.]
481-
WARN[2023-06-29T08:21:04-07:00] Error parsing information for chart ., skipping: values without documentation:
547+
INFO[2023-06-29T08:21:04-07:00] Found Chart directories [.]
548+
WARN[2023-06-29T08:21:04-07:00] Error parsing information for chart ., skipping: values without documentation:
482549
controller
483550
controller.name
484551
controller.livenessProbe.httpGet
485552
controller.livenessProbe.httpGet.port
486-
controller.publishService
553+
controller.publishService
487554
```
488555

489556
It is also possible to ignore specific errors using the `-y` argument.
490557

491558
```shell
492559
helm-docs -x -y="controller.name" -y="controller.service" -c example-charts/helm-3
493-
INFO[2023-06-29T08:23:40-07:00] Found Chart directories [.]
494-
WARN[2023-06-29T08:23:40-07:00] Error parsing information for chart ., skipping: values without documentation:
560+
INFO[2023-06-29T08:23:40-07:00] Found Chart directories [.]
561+
WARN[2023-06-29T08:23:40-07:00] Error parsing information for chart ., skipping: values without documentation:
495562
controller
496563
controller.image
497564
controller.extraVolumes.[0].name
@@ -502,5 +569,5 @@ controller.livenessProbe.httpGet.port
502569
controller.publishService
503570
controller.service.annotations
504571
controller.service.annotations.external-dns.alpha.kubernetes.io/hostname
505-
572+
506573
```

0 commit comments

Comments
 (0)