{{- define "custom.repository.organization" -}}
k8s-at-home
{{- end -}}

{{- define "custom.repository.url" -}}
https://github.com/k8s-at-home/charts
{{- end -}}

{{- define "custom.helm.url" -}}
https://k8s-at-home.com/charts/
{{- end -}}

{{- define "custom.helm.path" -}}
{{ template "custom.repository.organization" . }}/{{ template "chart.name" . }}
{{- end -}}

{{- define "custom.notes" -}}
**This chart is not maintained by the upstream project and any issues with the chart should be raised [here](https://github.com/k8s-at-home/charts/issues/new/choose)**
{{- end -}}

{{- define "custom.requirements" -}}
## Requirements

{{ template "chart.kubeVersionLine" . }}
{{- end -}}

{{- define "custom.dependencies" -}}
## Dependencies

{{ template "chart.requirementsTable" . }}
{{- end -}}

{{- define "custom.install.tldr" -}}
## TL;DR

```console
helm repo add {{ template "custom.repository.organization" . }} {{ template "custom.helm.url" . }}
helm repo update
helm install {{ template "chart.name" . }} {{ template "custom.helm.path" . }}
```
{{- end -}}

{{- define "custom.install" -}}
## Installing the Chart

To install the chart with the release name `{{ template "chart.name" . }}`

```console
helm install {{ template "chart.name" . }} {{ template "custom.helm.path" . }}
```
{{- end -}}

{{- define "custom.uninstall" -}}
## Uninstalling the Chart

To uninstall the `{{ template "chart.name" . }}` deployment

```console
helm uninstall {{ template "chart.name" . }}
```

The command removes all the Kubernetes components associated with the chart **including persistent volumes** and deletes the release.
{{- end -}}

{{- define "custom.configuration.header" -}}
## Configuration
{{- end -}}

{{- define "custom.configuration.readValues" -}}
Read through the [values.yaml](./values.yaml) file. It has several commented out suggested values.
Other values may be used from the [values.yaml](https://github.com/k8s-at-home/library-charts/tree/main/charts/stable/common/values.yaml) from the [common library](https://github.com/k8s-at-home/library-charts/tree/main/charts/stable/common).
{{- end -}}

{{- define "custom.configuration.example.set" -}}
Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`.

```console
helm install {{ template "chart.name" . }} \
  --set env.TZ="America/New York" \
    {{ template "custom.helm.path" . }}
```
{{- end -}}

{{- define "custom.configuration.example.file" -}}
Alternatively, a YAML file that specifies the values for the above parameters can be provided while installing the chart.

```console
helm install {{ template "chart.name" . }} {{ template "custom.helm.path" . }} -f values.yaml
```
{{- end -}}

{{- define "custom.valuesSection" -}}
## Values

**Important**: When deploying an application Helm chart you can add more values from our common library chart [here](https://github.com/k8s-at-home/library-charts/tree/main/charts/stable/common)

{{ template "chart.valuesTable" . }}
{{- end -}}

{{- define "custom.support" -}}
## Support

- See the [Docs](https://docs.k8s-at-home.com/our-helm-charts/getting-started/)
- Open an [issue](https://github.com/k8s-at-home/charts/issues/new/choose)
- Ask a [question](https://github.com/k8s-at-home/organization/discussions)
- Join our [Discord](https://discord.gg/sTMX7Vh) community
{{- end -}}

{{- define "custom.changelog" -}}
{{ $changeTypes := list "added" "changed" "fixed" }}
## Changelog

### Version {{ template "chart.version" . }}

{{ range $changeType := $changeTypes }}
  {{- with (index $.Annotations "artifacthub.io/changes") }}
    {{- print "#### " ($changeType | title)  | nindent 0  }}
    {{- print "" | nindent 0  }}
    {{- $changesFound := false }}
    {{- $changes := ((print "changes:\n" .) | fromYaml).changes }}
    {{- range $changes }}
      {{- if eq .kind $changeType }}
        {{- print "* " .description  | nindent 0 }}
        {{- $changesFound = true }}
      {{- end }}
    {{- end }}
    {{- if not $changesFound }}
      {{- print "N/A" | nindent 0 }}
    {{- end }}
    {{- print "" | nindent 0  }}
  {{- end }}
{{- end }}

### Older versions

A historical overview of changes can be found on [ArtifactHUB](https://artifacthub.io/packages/helm/k8s-at-home/{{- template "chart.name" . }}?modal=changelog)

{{- end -}}

{{ template "chart.header" . }}

{{ template "chart.versionBadge" . }}{{ template "chart.typeBadge" . }}{{ template "chart.appVersionBadge" . }}

{{ template "chart.description" . }}

{{ template "custom.notes" . }}

{{ template "chart.sourcesSection" . }}

{{ template "custom.requirements" . }}

{{ template "custom.dependencies" . }}

{{ template "custom.install.tldr" . }}

{{ template "custom.install" . }}

{{ template "custom.uninstall" . }}

{{ template "custom.configuration.header" . }}

{{ template "custom.configuration.readValues" . }}

{{ template "custom.configuration.example.set" . }}

{{ template "custom.configuration.example.file" . }}

{{ template "custom.custom.configuration" . }}

{{ template "custom.valuesSection" . }}

{{ template "custom.changelog" . }}

{{ template "custom.support" . }}

{{ template "helm-docs.versionFooter" . }}
{{ "" }}
