|
| 1 | +{{/* vim: set filetype=mustache: */}} |
| 2 | +{{/* |
| 3 | +Expand the name of the chart. |
| 4 | +*/}} |
| 5 | +{{- define "argo-cd.name" -}} |
| 6 | +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}} |
| 7 | +{{- end -}} |
| 8 | + |
| 9 | +{{/* |
| 10 | +Create a default fully qualified app name. |
| 11 | +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). |
| 12 | +If release name contains chart name it will be used as a full name. |
| 13 | +*/}} |
| 14 | +{{- define "argo-cd.fullname" -}} |
| 15 | +{{- if .Values.fullnameOverride -}} |
| 16 | +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}} |
| 17 | +{{- else -}} |
| 18 | +{{- $name := default .Chart.Name .Values.nameOverride -}} |
| 19 | +{{- if contains $name .Release.Name -}} |
| 20 | +{{- .Release.Name | trunc 63 | trimSuffix "-" -}} |
| 21 | +{{- else -}} |
| 22 | +{{- $name | trunc 63 | trimSuffix "-" -}} |
| 23 | +{{- end -}} |
| 24 | +{{- end -}} |
| 25 | +{{- end -}} |
| 26 | + |
| 27 | +{{/* |
| 28 | +Create controller name and version as used by the chart label. |
| 29 | +*/}} |
| 30 | +{{- define "argo-cd.controller.fullname" -}} |
| 31 | +{{- printf "%s-%s" (include "argo-cd.fullname" .) .Values.controller.name | trunc 63 | trimSuffix "-" -}} |
| 32 | +{{- end -}} |
| 33 | + |
| 34 | +{{/* |
| 35 | +Create dex name and version as used by the chart label. |
| 36 | +*/}} |
| 37 | +{{- define "argo-cd.dex.fullname" -}} |
| 38 | +{{- printf "%s-%s" (include "argo-cd.fullname" .) .Values.dex.name | trunc 63 | trimSuffix "-" -}} |
| 39 | +{{- end -}} |
| 40 | + |
| 41 | +{{/* |
| 42 | +Create redis name and version as used by the chart label. |
| 43 | +*/}} |
| 44 | +{{- define "argo-cd.redis.fullname" -}} |
| 45 | +{{- $redisHa := (index .Values "redis-ha") -}} |
| 46 | +{{- $redisHaContext := dict "Chart" (dict "Name" "redis-ha") "Release" .Release "Values" $redisHa -}} |
| 47 | +{{- if $redisHa.enabled -}} |
| 48 | + {{- if $redisHa.haproxy.enabled -}} |
| 49 | + {{- printf "%s-haproxy" (include "redis-ha.fullname" $redisHaContext) | trunc 63 | trimSuffix "-" -}} |
| 50 | + {{- end -}} |
| 51 | +{{- else -}} |
| 52 | +{{- printf "%s-%s" (include "argo-cd.fullname" .) .Values.redis.name | trunc 63 | trimSuffix "-" -}} |
| 53 | +{{- end -}} |
| 54 | +{{- end -}} |
| 55 | + |
| 56 | +{{/* |
| 57 | +Create argocd server name and version as used by the chart label. |
| 58 | +*/}} |
| 59 | +{{- define "argo-cd.server.fullname" -}} |
| 60 | +{{- printf "%s-%s" (include "argo-cd.fullname" .) .Values.server.name | trunc 63 | trimSuffix "-" -}} |
| 61 | +{{- end -}} |
| 62 | + |
| 63 | +{{/* |
| 64 | +Create argocd repo-server name and version as used by the chart label. |
| 65 | +*/}} |
| 66 | +{{- define "argo-cd.repoServer.fullname" -}} |
| 67 | +{{- printf "%s-%s" (include "argo-cd.fullname" .) .Values.repoServer.name | trunc 63 | trimSuffix "-" -}} |
| 68 | +{{- end -}} |
| 69 | + |
| 70 | +{{/* |
| 71 | +Create argocd application set name and version as used by the chart label. |
| 72 | +*/}} |
| 73 | +{{- define "argo-cd.applicationSet.fullname" -}} |
| 74 | +{{- printf "%s-%s" (include "argo-cd.fullname" .) .Values.applicationSet.name | trunc 63 | trimSuffix "-" -}} |
| 75 | +{{- end -}} |
| 76 | + |
| 77 | +{{/* |
| 78 | +Create argocd notifications name and version as used by the chart label. |
| 79 | +*/}} |
| 80 | +{{- define "argo-cd.notifications.fullname" -}} |
| 81 | +{{- printf "%s-%s" (include "argo-cd.fullname" .) .Values.notifications.name | trunc 63 | trimSuffix "-" -}} |
| 82 | +{{- end -}} |
| 83 | + |
| 84 | +{{/* |
| 85 | +Create the name of the controller service account to use |
| 86 | +*/}} |
| 87 | +{{- define "argo-cd.controllerServiceAccountName" -}} |
| 88 | +{{- if .Values.controller.serviceAccount.create -}} |
| 89 | + {{ default (include "argo-cd.controller.fullname" .) .Values.controller.serviceAccount.name }} |
| 90 | +{{- else -}} |
| 91 | + {{ default "default" .Values.controller.serviceAccount.name }} |
| 92 | +{{- end -}} |
| 93 | +{{- end -}} |
| 94 | + |
| 95 | +{{/* |
| 96 | +Create the name of the dex service account to use |
| 97 | +*/}} |
| 98 | +{{- define "argo-cd.dexServiceAccountName" -}} |
| 99 | +{{- if .Values.dex.serviceAccount.create -}} |
| 100 | + {{ default (include "argo-cd.dex.fullname" .) .Values.dex.serviceAccount.name }} |
| 101 | +{{- else -}} |
| 102 | + {{ default "default" .Values.dex.serviceAccount.name }} |
| 103 | +{{- end -}} |
| 104 | +{{- end -}} |
| 105 | + |
| 106 | +{{/* |
| 107 | +Create the name of the redis service account to use |
| 108 | +*/}} |
| 109 | +{{- define "argo-cd.redisServiceAccountName" -}} |
| 110 | +{{- if .Values.redis.serviceAccount.create -}} |
| 111 | + {{ default (include "argo-cd.redis.fullname" .) .Values.redis.serviceAccount.name }} |
| 112 | +{{- else -}} |
| 113 | + {{ default "default" .Values.redis.serviceAccount.name }} |
| 114 | +{{- end -}} |
| 115 | +{{- end -}} |
| 116 | + |
| 117 | +{{/* |
| 118 | +Create the name of the Argo CD server service account to use |
| 119 | +*/}} |
| 120 | +{{- define "argo-cd.serverServiceAccountName" -}} |
| 121 | +{{- if .Values.server.serviceAccount.create -}} |
| 122 | + {{ default (include "argo-cd.server.fullname" .) .Values.server.serviceAccount.name }} |
| 123 | +{{- else -}} |
| 124 | + {{ default "default" .Values.server.serviceAccount.name }} |
| 125 | +{{- end -}} |
| 126 | +{{- end -}} |
| 127 | + |
| 128 | +{{/* |
| 129 | +Create the name of the repo-server service account to use |
| 130 | +*/}} |
| 131 | +{{- define "argo-cd.repoServerServiceAccountName" -}} |
| 132 | +{{- if .Values.repoServer.serviceAccount.create -}} |
| 133 | + {{ default (include "argo-cd.repoServer.fullname" .) .Values.repoServer.serviceAccount.name }} |
| 134 | +{{- else -}} |
| 135 | + {{ default "default" .Values.repoServer.serviceAccount.name }} |
| 136 | +{{- end -}} |
| 137 | +{{- end -}} |
| 138 | + |
| 139 | +{{/* |
| 140 | +Create the name of the application set service account to use |
| 141 | +*/}} |
| 142 | +{{- define "argo-cd.applicationSetServiceAccountName" -}} |
| 143 | +{{- if .Values.applicationSet.serviceAccount.create -}} |
| 144 | + {{ default (include "argo-cd.applicationSet.fullname" .) .Values.applicationSet.serviceAccount.name }} |
| 145 | +{{- else -}} |
| 146 | + {{ default "default" .Values.applicationSet.serviceAccount.name }} |
| 147 | +{{- end -}} |
| 148 | +{{- end -}} |
| 149 | + |
| 150 | +{{/* |
| 151 | +Create the name of the notifications service account to use |
| 152 | +*/}} |
| 153 | +{{- define "argo-cd.notificationsServiceAccountName" -}} |
| 154 | +{{- if .Values.notifications.serviceAccount.create -}} |
| 155 | + {{ default (include "argo-cd.notifications.fullname" .) .Values.notifications.serviceAccount.name }} |
| 156 | +{{- else -}} |
| 157 | + {{ default "default" .Values.notifications.serviceAccount.name }} |
| 158 | +{{- end -}} |
| 159 | +{{- end -}} |
| 160 | + |
| 161 | +{{/* |
| 162 | +Create the name of the notifications bots slack service account to use |
| 163 | +*/}} |
| 164 | +{{- define "argo-cd.notificationsBotsSlackServiceAccountName" -}} |
| 165 | +{{- if .Values.notifications.bots.slack.serviceAccount.create -}} |
| 166 | + {{ default (include "argo-cd.notifications.fullname" .) .Values.notifications.bots.slack.serviceAccount.name }} |
| 167 | +{{- else -}} |
| 168 | + {{ default "default" .Values.notifications.bots.slack.serviceAccount.name }} |
| 169 | +{{- end -}} |
| 170 | +{{- end -}} |
| 171 | + |
| 172 | +{{/* |
| 173 | +Create chart name and version as used by the chart label. |
| 174 | +*/}} |
| 175 | +{{- define "argo-cd.chart" -}} |
| 176 | +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}} |
| 177 | +{{- end -}} |
| 178 | + |
| 179 | +{{/* |
| 180 | +Common labels |
| 181 | +*/}} |
| 182 | +{{- define "argo-cd.labels" -}} |
| 183 | +helm.sh/chart: {{ include "argo-cd.chart" .context }} |
| 184 | +{{ include "argo-cd.selectorLabels" (dict "context" .context "component" .component "name" .name) }} |
| 185 | +app.kubernetes.io/managed-by: {{ .context.Release.Service }} |
| 186 | +app.kubernetes.io/part-of: argocd |
| 187 | +{{- with .context.Values.global.additionalLabels }} |
| 188 | +{{ toYaml . }} |
| 189 | +{{- end }} |
| 190 | +{{- end }} |
| 191 | + |
| 192 | +{{/* |
| 193 | +Selector labels |
| 194 | +*/}} |
| 195 | +{{- define "argo-cd.selectorLabels" -}} |
| 196 | +{{- if .name -}} |
| 197 | +app.kubernetes.io/name: {{ include "argo-cd.name" .context }}-{{ .name }} |
| 198 | +{{ end -}} |
| 199 | +app.kubernetes.io/instance: {{ .context.Release.Name }} |
| 200 | +{{- if .component }} |
| 201 | +app.kubernetes.io/component: {{ .component }} |
| 202 | +{{- end }} |
| 203 | +{{- end }} |
| 204 | + |
| 205 | +{{/* |
| 206 | +Return the appropriate apiVersion for ingress |
| 207 | +*/}} |
| 208 | +{{- define "argo-cd.ingress.apiVersion" -}} |
| 209 | +{{- if .Values.apiVersionOverrides.ingress -}} |
| 210 | +{{- print .Values.apiVersionOverrides.ingress -}} |
| 211 | +{{- else if semverCompare "<1.14-0" (include "argo-cd.kubeVersion" $) -}} |
| 212 | +{{- print "extensions/v1beta1" -}} |
| 213 | +{{- else if semverCompare "<1.19-0" (include "argo-cd.kubeVersion" $) -}} |
| 214 | +{{- print "networking.k8s.io/v1beta1" -}} |
| 215 | +{{- else -}} |
| 216 | +{{- print "networking.k8s.io/v1" -}} |
| 217 | +{{- end -}} |
| 218 | +{{- end -}} |
| 219 | + |
| 220 | +{{/* |
| 221 | +Return the target Kubernetes version |
| 222 | +*/}} |
| 223 | +{{- define "argo-cd.kubeVersion" -}} |
| 224 | + {{- default .Capabilities.KubeVersion.Version .Values.kubeVersionOverride }} |
| 225 | +{{- end -}} |
| 226 | + |
| 227 | +{{/* |
| 228 | +Argo Configuration Preset Values (Incluenced by Values configuration) |
| 229 | +*/}} |
| 230 | +{{- define "argo-cd.config.presets" -}} |
| 231 | + {{- if .Values.configs.styles }} |
| 232 | +ui.cssurl: "./custom/custom.styles.css" |
| 233 | + {{- end }} |
| 234 | +{{- end -}} |
| 235 | + |
| 236 | +{{/* |
| 237 | +Merge Argo Configuration with Preset Configuration |
| 238 | +*/}} |
| 239 | +{{- define "argo-cd.config" -}} |
| 240 | + {{- if .Values.server.configEnabled -}} |
| 241 | +{{- toYaml (mergeOverwrite (default dict (fromYaml (include "argo-cd.config.presets" $))) .Values.server.config) }} |
| 242 | + {{- end -}} |
| 243 | +{{- end -}} |
| 244 | + |
| 245 | +{{/* |
| 246 | +Return the default Argo CD app version |
| 247 | +*/}} |
| 248 | +{{- define "argo-cd.defaultTag" -}} |
| 249 | + {{- default .Chart.AppVersion .Values.global.image.tag }} |
| 250 | +{{- end -}} |
| 251 | + |
| 252 | +{{/* |
| 253 | +Create the name of the notifications controller secret to use |
| 254 | +*/}} |
| 255 | +{{- define "argo-cd.notifications.secretName" -}} |
| 256 | +{{- if .Values.notifications.secret.create -}} |
| 257 | + {{ default (printf "%s-secret" (include "argo-cd.notifications.fullname" .)) .Values.notifications.secret.name }} |
| 258 | +{{- else -}} |
| 259 | + {{ default "argocd-notifications-secret" .Values.notifications.secret.name }} |
| 260 | +{{- end -}} |
| 261 | +{{- end -}} |
| 262 | + |
| 263 | +{{/* |
| 264 | +Create the name of the configmap to use |
| 265 | +*/}} |
| 266 | +{{- define "argo-cd.notifications.configMapName" -}} |
| 267 | +{{- if .Values.notifications.cm.create -}} |
| 268 | + {{ default (printf "%s-cm" (include "argo-cd.notifications.fullname" .)) .Values.notifications.cm.name }} |
| 269 | +{{- else -}} |
| 270 | + {{ default "argocd-notifications-cm" .Values.notifications.cm.name }} |
| 271 | +{{- end -}} |
| 272 | +{{- end -}} |
0 commit comments