[COMMON] Fix bad subchartDot retrieving
[oom.git] / kubernetes / common / readinessCheck / templates / _readinessCheck.tpl
1 {{/*
2 # Copyright © 2020 Orange
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #       http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 */}}
16
17 {{/*
18   Generate readiness part for a pod
19   Will look by default to .Values.wait_for
20
21   Value of wait_for is an array of all pods /jobs to wait:
22
23   Example:
24
25   wait_for:
26     - aaf-locate
27     - aaf-cm
28     - aaf-service
29
30   The function can takes two arguments (inside a dictionary):
31      - .dot : environment (.)
32      - .wait_for : list of containers / jobs to wait for (default to
33                    .Values.wait_for)
34
35   Example calls:
36     {{ include "common.readinessCheck.waitFor" . }}
37     {{ include "common.readinessCheck.waitFor" (dict "dot" . "wait_for" .Values.where.my.wait_for.is ) }}
38 */}}
39 {{- define "common.readinessCheck.waitFor" -}}
40 {{-   $dot := default . .dot -}}
41 {{-   $initRoot := default $dot.Values.readinessCheck .initRoot -}}
42 {{/*  Our version of helm doesn't support deepCopy so we need this nasty trick */}}
43 {{-   $subchartDot := fromJson (include "common.subChartDot" (dict "dot" $dot "initRoot" $initRoot)) }}
44 {{-   $wait_for := default $initRoot.wait_for .wait_for -}}
45 - name: {{ include "common.name" $dot }}-{{ $wait_for.name }}-readiness
46   image: "{{ $subchartDot.Values.global.readinessRepository }}/{{ $subchartDot.Values.global.readinessImage }}"
47   imagePullPolicy: {{ $subchartDot.Values.global.pullPolicy | default $subchartDot.Values.pullPolicy }}
48   command:
49   - /root/ready.py
50   args:
51   {{- range $container := $wait_for.containers }}
52   - --container-name
53   - {{ tpl $container $dot }}
54   {{- end }}
55   env:
56   - name: NAMESPACE
57     valueFrom:
58       fieldRef:
59         apiVersion: v1
60         fieldPath: metadata.namespace
61   resources:
62     limits:
63       cpu: {{ $subchartDot.Values.limits.cpu }}
64       memory: {{ $subchartDot.Values.limits.memory }}
65     requests:
66       cpu: {{ $subchartDot.Values.requests.cpu }}
67       memory: {{ $subchartDot.Values.requests.memory }}
68 {{- end -}}