|
| 1 | +{{/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
| 2 | + * |
| 3 | + * Name (defaults to "haproxy-ingress") and a fully qualified name |
| 4 | + * (defaults to "<release>-haproxy-ingress") of controller and a variant with `.Values.defaultBackend.name` |
| 5 | + * for the default backend. |
| 6 | + * |
| 7 | + * We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). |
| 8 | + * If release name contains the chart name, it will be used as a full name. |
| 9 | + * |
| 10 | + */}} |
| 11 | +{{- define "haproxy-ingress.name" -}} |
| 12 | + {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} |
| 13 | +{{- end }} |
| 14 | + |
| 15 | +{{- define "haproxy-ingress.fullname" -}} |
| 16 | + {{- if .Values.fullnameOverride }} |
| 17 | + {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} |
| 18 | + {{- else }} |
| 19 | + {{- $name := default .Chart.Name .Values.nameOverride }} |
| 20 | + {{- if contains $name .Release.Name }} |
| 21 | + {{- .Release.Name | trunc 63 | trimSuffix "-" }} |
| 22 | + {{- else }} |
| 23 | + {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} |
| 24 | + {{- end }} |
| 25 | + {{- end }} |
| 26 | +{{- end }} |
| 27 | + |
| 28 | +{{- define "haproxy-ingress.defaultBackend.name" -}} |
| 29 | + {{- printf "%s-%s" .Chart.Name .Values.defaultBackend.name | trunc 63 | trimSuffix "-" }} |
| 30 | +{{- end }} |
| 31 | + |
| 32 | +{{- define "haproxy-ingress.defaultBackend.fullname" -}} |
| 33 | + {{- $name := default .Chart.Name .Values.nameOverride }} |
| 34 | + {{- if contains $name .Release.Name }} |
| 35 | + {{- printf "%s-%s" .Release.Name .Values.defaultBackend.name | trunc 63 | trimSuffix "-" }} |
| 36 | + {{- else }} |
| 37 | + {{- printf "%s-%s-%s" .Release.Name $name .Values.defaultBackend.name | trunc 63 | trimSuffix "-" }} |
| 38 | + {{- end }} |
| 39 | +{{- end }} |
| 40 | + |
| 41 | + |
| 42 | +{{/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
| 43 | + * |
| 44 | + * Common and selector labels |
| 45 | + * |
| 46 | + * We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). |
| 47 | + * |
| 48 | + */}} |
| 49 | +{{- define "haproxy-ingress.chart" -}} |
| 50 | + {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} |
| 51 | +{{- end }} |
| 52 | + |
| 53 | +{{- define "haproxy-ingress.labels" -}} |
| 54 | +helm.sh/chart: {{ include "haproxy-ingress.chart" . }} |
| 55 | +{{ include "haproxy-ingress.selectorLabels" . }} |
| 56 | +{{- if .Chart.AppVersion }} |
| 57 | +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} |
| 58 | +{{- end }} |
| 59 | +app.kubernetes.io/managed-by: {{ .Release.Service }} |
| 60 | +{{- end }} |
| 61 | + |
| 62 | +{{- define "haproxy-ingress.selectorLabels" -}} |
| 63 | +app.kubernetes.io/name: {{ include "haproxy-ingress.name" . }} |
| 64 | +app.kubernetes.io/instance: {{ .Release.Name }} |
| 65 | +{{- end }} |
| 66 | + |
| 67 | +{{- define "haproxy-ingress.defaultBackend.labels" -}} |
| 68 | +helm.sh/chart: {{ include "haproxy-ingress.chart" . }} |
| 69 | +{{ include "haproxy-ingress.defaultBackend.selectorLabels" . }} |
| 70 | +{{- if .Chart.AppVersion }} |
| 71 | +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} |
| 72 | +{{- end }} |
| 73 | +app.kubernetes.io/managed-by: {{ .Release.Service }} |
| 74 | +{{- end }} |
| 75 | + |
| 76 | +{{- define "haproxy-ingress.defaultBackend.selectorLabels" -}} |
| 77 | +app.kubernetes.io/name: {{ include "haproxy-ingress.defaultBackend.name" . }} |
| 78 | +app.kubernetes.io/instance: {{ .Release.Name }} |
| 79 | +{{- end }} |
| 80 | + |
| 81 | + |
| 82 | +{{/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
| 83 | + * |
| 84 | + * Create the name of the service account to use |
| 85 | + * |
| 86 | + */}} |
| 87 | +{{- define "haproxy-ingress.serviceAccountName" -}} |
| 88 | + {{- if .Values.serviceAccount.create }} |
| 89 | + {{- default (include "haproxy-ingress.fullname" .) .Values.serviceAccount.name }} |
| 90 | + {{- else }} |
| 91 | + {{- default "default" .Values.serviceAccount.name }} |
| 92 | + {{- end }} |
| 93 | +{{- end }} |
| 94 | + |
| 95 | + |
| 96 | +{{/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * |
| 97 | + * |
| 98 | + * Construct the path for publish-service |
| 99 | + * |
| 100 | + */}} |
| 101 | +{{- define "haproxy-ingress.controller.publishServicePath" -}} |
| 102 | + {{- if .Values.controller.publishService.pathOverride }} |
| 103 | + {{- .Values.controller.publishService.pathOverride | trimSuffix "-" }} |
| 104 | + {{- else }} |
| 105 | + {{- printf "%s/%s" "$(POD_NAMESPACE)" (include "haproxy-ingress.fullname" .) | trimSuffix "-" }} |
| 106 | + {{- end }} |
| 107 | +{{- end }} |
0 commit comments