Merge "[AAI] Add model-loader tracing config"
[oom.git] / kubernetes / platform / components / oauth2-proxy / components / oauth2-proxy / templates / _helpers.tpl
1 {{/* vim: set filetype=mustache: */}}
2 {{/*
3 Expand the name of the chart.
4 */}}
5 {{- define "oauth2-proxy.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 "oauth2-proxy.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 {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
23 {{- end -}}
24 {{- end -}}
25 {{- end -}}
26
27 {{/*
28 Create chart name and version as used by the chart label.
29 */}}
30 {{- define "oauth2-proxy.chart" -}}
31 {{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
32 {{- end -}}
33
34 {{/*
35 Generate basic labels
36 */}}
37 {{- define "oauth2-proxy.labels" }}
38 helm.sh/chart: {{ include "oauth2-proxy.chart" . }}
39 app.kubernetes.io/managed-by: {{ .Release.Service }}
40 app.kubernetes.io/component: authentication-proxy
41 app.kubernetes.io/part-of: {{ template "oauth2-proxy.name" . }}
42 {{- include "oauth2-proxy.selectorLabels" . }}
43 {{- if .Chart.AppVersion }}
44 app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
45 {{- end }}
46 {{- if .Values.customLabels }}
47 {{ toYaml .Values.customLabels }}
48 {{- end }}
49 {{- end }}
50
51 {{/*
52 Selector labels
53 */}}
54 {{- define "oauth2-proxy.selectorLabels" }}
55 app.kubernetes.io/name: {{ include "oauth2-proxy.name" . }}
56 app.kubernetes.io/instance: {{ .Release.Name }}
57 {{- end }}
58
59 {{/*
60 Get the secret name.
61 */}}
62 {{- define "oauth2-proxy.secretName" -}}
63 {{- if .Values.config.existingSecret -}}
64 {{- printf "%s" .Values.config.existingSecret -}}
65 {{- else -}}
66 {{- printf "%s" (include "oauth2-proxy.fullname" .) -}}
67 {{- end -}}
68 {{- end -}}
69
70 {{/*
71 Create the name of the service account to use
72 */}}
73 {{- define "oauth2-proxy.serviceAccountName" -}}
74 {{- if .Values.serviceAccount.enabled -}}
75     {{ default (include "oauth2-proxy.fullname" .) .Values.serviceAccount.name }}
76 {{- else -}}
77     {{ default "default" .Values.serviceAccount.name }}
78 {{- end -}}
79 {{- end -}}
80
81 {{/*
82 Redis subcharts fullname
83 */}}
84 {{- define "oauth2-proxy.redis.fullname" -}}
85 {{- if .Values.redis.enabled -}}
86 {{- include "common.names.fullname" (dict "Chart" (dict "Name" "redis") "Release" .Release "Values" .Values.redis) -}}
87 {{- else -}}
88 {{ fail "attempting to use redis subcharts fullname, even though the subchart is not enabled. This will lead to misconfiguration" }}
89 {{- end -}}
90 {{- end -}}
91
92 {{/*
93 Compute the redis url if not set explicitly.
94 */}}
95 {{- define "oauth2-proxy.redis.StandaloneUrl" -}}
96 {{- if .Values.sessionStorage.redis.standalone.connectionUrl -}}
97 {{ .Values.sessionStorage.redis.standalone.connectionUrl }}
98 {{- else if .Values.redis.enabled -}}
99 {{- printf "redis://%s-master:%.0f" (include "oauth2-proxy.redis.fullname" .) .Values.redis.master.service.ports.redis -}}
100 {{- else -}}
101 {{ fail "please set sessionStorage.redis.standalone.connectionUrl or enable the redis subchart via redis.enabled" }}
102 {{- end -}}
103 {{- end -}}
104
105 {{/*
106 Returns the version
107 */}}
108 {{- define "oauth2-proxy.version" -}}
109 {{ trimPrefix "v" (lower (.Values.image.tag | default (printf "v%s" .Chart.AppVersion))) }}
110 {{- end -}}