Skip to content

Commit b6e6c48

Browse files
authored
Merge pull request #46 from matheusfm/feature/name-template
add chart name template
2 parents 3cfab7a + 4e48985 commit b6e6c48

File tree

6 files changed

+37
-0
lines changed

6 files changed

+37
-0
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ The templates generated by the tool are shown below, and can be included in your
8787
| Name | Description |
8888
|------|-------------|
8989
| chart.header | The main heading of the generated markdown file |
90+
| chart.name | The _name_ field from the chart's `Chart.yaml` file |
9091
| chart.deprecationWarning | A deprecation warning which is displayed when the _deprecated_ field from the chart's `Chart.yaml` file is `true` |
9192
| chart.description | A description line containing the _description_ field from the chart's `Chart.yaml` file, or "" if that field is not set |
9293
| chart.version | The _version_ field from the chart's `Chart.yaml` file |

example-charts/custom-template/README.md

+9
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@ aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in volup
1212
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
1313
culpa qui officia deserunt mollit anim id est laborum.
1414

15+
## Installing the Chart
16+
17+
To install the chart with the release name `my-release`:
18+
19+
```console
20+
$ helm repo add foo-bar http://charts.foo-bar.com
21+
$ helm install my-release foo-bar/custom-template
22+
```
23+
1524
## Requirements
1625

1726
| Repository | Name | Version |

example-charts/custom-template/README.md.gotmpl

+9
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,15 @@ aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in volup
1111
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
1212
culpa qui officia deserunt mollit anim id est laborum.
1313

14+
## Installing the Chart
15+
16+
To install the chart with the release name `my-release`:
17+
18+
```console
19+
$ helm repo add foo-bar http://charts.foo-bar.com
20+
$ helm install my-release foo-bar/{{ template "chart.name" . }}
21+
```
22+
1423
{{ template "chart.requirementsSection" . }}
1524

1625
{{ template "chart.valuesSection" . }}

example-charts/full-template/README.md

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44

55
> **:exclamation: This Helm Chart is deprecated!**
66
7+
## `chart.name`
8+
9+
full-template
10+
711
## `chart.description`
812

913
A chart for showing every README-element

example-charts/full-template/README.md.gotmpl

+4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010

1111
{{ template "chart.deprecationWarning" . }}
1212

13+
## `chart.name`
14+
15+
{{ template "chart.name" . }}
16+
1317
## `chart.description`
1418

1519
{{ template "chart.description" . }}

pkg/document/template.go

+10
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,15 @@ const defaultDocumentationTemplate = `{{ template "chart.header" . }}
3131
{{ template "chart.valuesSection" . }}
3232
`
3333

34+
func getNameTemplate() string {
35+
nameBuilder := strings.Builder{}
36+
nameBuilder.WriteString(`{{ define "chart.name" }}`)
37+
nameBuilder.WriteString("{{ .Name }}")
38+
nameBuilder.WriteString("{{ end }}")
39+
40+
return nameBuilder.String()
41+
}
42+
3443
func getHeaderTemplate() string {
3544
headerTemplateBuilder := strings.Builder{}
3645
headerTemplateBuilder.WriteString(`{{ define "chart.header" }}`)
@@ -235,6 +244,7 @@ func getDocumentationTemplates(chartDirectory string) ([]string, error) {
235244
}
236245

237246
return []string{
247+
getNameTemplate(),
238248
getHeaderTemplate(),
239249
getDeprecatedTemplate(),
240250
getAppVersionTemplate(),

0 commit comments

Comments
 (0)