diff --git a/templates/_helpers.tpl b/templates/_helpers.tpl index f88c7ef..f4af16f 100644 --- a/templates/_helpers.tpl +++ b/templates/_helpers.tpl @@ -6,13 +6,7 @@ {{- end }} {{- end }} -{{- define "helm-library.common.required" -}} -{{- "No value found for '%s' in the template" -}} -{{- end -}} - -{{- define "helm-library.common.labels" -}} -{{- $message := include "helm-library.required" . -}} -app.kubernetes.io/name: {{ required (printf $message "name") .Values.name | quote }} +{{- define "helm-library.common.labels" }} app.kubernetes.io/instance: {{ .Release.Name }} app.kubernetes.io/managed-by: {{ .Release.Service }} helm.sh/chart: {{ .Chart.Name }} diff --git a/templates/_ingress.yaml b/templates/_ingress.yaml index 6c9ac79..60c0bf1 100644 --- a/templates/_ingress.yaml +++ b/templates/_ingress.yaml @@ -1,30 +1,41 @@ {{- $ := .}} {{- define "helm-library.ingress.template" }} -{{- $required := include "helm-library.common.required" $ }} -apiVersion: networking.k8s.io/v1 {{ include "helm-library.ingress.apiVersion" $ }} +{{- range .Values.ingress }} +{{- $ingressDict := dict }} +--- +apiVersion: {{ include "helm-library.ingress.apiVersion" $ }} kind: Ingress metadata: - name: {{ required (printf $required "name") .Values.name | quote }} + name: {{ required "No value found for '%s'" .name | quote }} labels: - {{ include "helm-library.common.labels" | indent 4 }} + {{- include "helm-library.common.labels" $ | indent 4 }} annotations: - kubernetes.io/ingress.class: {{ .Values.ingress.class | default "nginx" | quote }} - {{ toYaml $.annotations | indent 4 }} + kubernetes.io/ingress.class: {{ .className | default "nginx" | quote }} + {{- if .annotations }} + {{- toYaml .annotations | indent 4 }} + {{- end }} spec: - ingressClassName: {{ $.className | default "nginx" }} - {{- if $.host }} + ingressClassName: {{ .className | default "nginx" }} + {{- if .host }} tls: - hosts: - - {{ $.host }} - secretName: {{ $.name }}-tls + - {{ .host }} + secretName: {{ .name }}-tls {{- end }} rules: - {{- if $.host }} - - host: {{ $.host }} + {{- if .host }} + - host: {{ .host }} http: {{- else }} - http: {{- end }} paths: - {{ include "helm-library.ingress.builder" $.paths | indent 6 }} + +{{- if eq "networking.k8s.io/v1" (include "helm-library.ingress.apiVersion" $) }} +{{- $_ := set $ingressDict "networking" .paths }} +{{- else }} +{{- $_ := set $ingressDict "extension" .paths }} +{{- end }} +{{- include "helm-library.ingress.builder" $ingressDict | indent 6 }} +{{- end }} {{- end }} \ No newline at end of file diff --git a/templates/_secret.yaml b/templates/_secret.yaml index 173607d..02410d7 100644 --- a/templates/_secret.yaml +++ b/templates/_secret.yaml @@ -1,12 +1,11 @@ {{- define "helm-library.secret.template" -}} -{{- $required := include "helm-library.common.required" . -}} apiVersion: v1 kind: Secret metadata: - name: {{ required (printf $required "name") .Values.name | quote }} + name: {{ required "No value found for '%s'" .name | quote }} labels: {{- include "helm-library.common.labels" . | nindent 4 }} -type: {{ required (printf $required "secret.type") .Values.secret.type | quote }} +type: {{ required "No value found for '%s'" .type | quote }} data: {} {{- end }} {{/* include this */}}