Skip to content

add chart name template #46

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ The templates generated by the tool are shown below, and can be included in your
| Name | Description |
|------|-------------|
| chart.header | The main heading of the generated markdown file |
| chart.name | The _name_ field from the chart's `Chart.yaml` file |
| chart.deprecationWarning | A deprecation warning which is displayed when the _deprecated_ field from the chart's `Chart.yaml` file is `true` |
| chart.description | A description line containing the _description_ field from the chart's `Chart.yaml` file, or "" if that field is not set |
| chart.version | The _version_ field from the chart's `Chart.yaml` file |
Expand Down
9 changes: 9 additions & 0 deletions example-charts/custom-template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@ aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in volup
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim id est laborum.

## Installing the Chart

To install the chart with the release name `my-release`:

```console
$ helm repo add foo-bar http://charts.foo-bar.com
$ helm install my-release foo-bar/custom-template
```

## Requirements

| Repository | Name | Version |
Expand Down
9 changes: 9 additions & 0 deletions example-charts/custom-template/README.md.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@ aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in volup
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
culpa qui officia deserunt mollit anim id est laborum.

## Installing the Chart

To install the chart with the release name `my-release`:

```console
$ helm repo add foo-bar http://charts.foo-bar.com
$ helm install my-release foo-bar/{{ template "chart.name" . }}
```

{{ template "chart.requirementsSection" . }}

{{ template "chart.valuesSection" . }}
4 changes: 4 additions & 0 deletions example-charts/full-template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

> **:exclamation: This Helm Chart is deprecated!**

## `chart.name`

full-template

## `chart.description`

A chart for showing every README-element
Expand Down
4 changes: 4 additions & 0 deletions example-charts/full-template/README.md.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@

{{ template "chart.deprecationWarning" . }}

## `chart.name`

{{ template "chart.name" . }}

## `chart.description`

{{ template "chart.description" . }}
Expand Down
10 changes: 10 additions & 0 deletions pkg/document/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ const defaultDocumentationTemplate = `{{ template "chart.header" . }}
{{ template "chart.valuesSection" . }}
`

func getNameTemplate() string {
nameBuilder := strings.Builder{}
nameBuilder.WriteString(`{{ define "chart.name" }}`)
nameBuilder.WriteString("{{ .Name }}")
nameBuilder.WriteString("{{ end }}")

return nameBuilder.String()
}

func getHeaderTemplate() string {
headerTemplateBuilder := strings.Builder{}
headerTemplateBuilder.WriteString(`{{ define "chart.header" }}`)
Expand Down Expand Up @@ -235,6 +244,7 @@ func getDocumentationTemplates(chartDirectory string) ([]string, error) {
}

return []string{
getNameTemplate(),
getHeaderTemplate(),
getDeprecatedTemplate(),
getAppVersionTemplate(),
Expand Down