-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathl10n-extra.yaml
46 lines (45 loc) · 1.64 KB
/
l10n-extra.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
{{- $groups := dict }}
{{- $curName := "" }}
{{- $curLines := list }}
{{- range .Files.Lines "chart.l10n" }}
{{- if hasPrefix "[" . }}
{{- if ne $curName "" }}
{{- $_ := set $groups $curName (without $curLines "") }}
{{- end }}
{{- $curName = . | replace "[" "" | replace "]" "" }}
{{- $curLines = list }}
{{- else -}}
{{- $curLines = append $curLines . -}}
{{- end }}
{{- end }}
{{- if ne $curName "" }}
{{- $_ := set $groups $curName (without $curLines "") -}}
{{- end }}
{{- range $key, $value := $groups }}
{{- $chart := splitn ":" 4 $key }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "CHARTNAME.fullname" $ }}-{{ tpl (default $chart._0 $chart._2) $ }}-l10n
labels:
app.kubernetes.io/name: {{ tpl $chart._0 $ }}
helm.sh/chart: {{ include "CHARTNAME.chart" $ }}
app.kubernetes.io/instance: {{ tpl (default EXTRA_INSTANCE_DEFAULT $chart._1) $ }}
app.kubernetes.io/managed-by: {{ $.Release.Service }}
{{- if $.Values.partOf }}
app.kubernetes.io/part-of: {{ tpl $.Values.partOf $ }}
{{- end }}
object.ravin.soc1.ir/type: l10n
annotations:
object.ravin.soc1.ir/priority: {{ default "2" $chart._3 | quote }}
data:
{{- $content := tpl (join "\n" $value) $ }}
{{/*
Convert to YAML format. Quote the string so that escape chars will work
But replace \s with the space char since it is not supported in YAML
*/}}
{{- $content = regexReplaceAll "([^\\\\](\\\\{2})*)\\\\s" $content "${1} " }}
{{- $yamlContent := regexReplaceAll "(.*?)=(.*)" $content "${1}: \"${2}\"" }}
{{- regexReplaceAll "(.*?)\\[(.*?)\\]?: (.*)" $yamlContent "${1}.${2}: ${3}" | nindent 2 }}
---
{{ end -}}