f76be4c1909add58b245b72840a2fad3cd47ebe1
[oom.git] / kubernetes / dcaegen2-services / common / dcaegen2-services-common / templates / _configmap.tpl
1 {{/*
2 # Copyright © 2017 Amdocs, Bell Canada
3 # Modifications Copyright © 2019 AT&T
4 # Copyright (c) 2021 J. F. Lucas.  All rights reserved.
5 # Copyright (c) 2021 Nordix Foundation.
6 #
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
10 #
11 #       http://www.apache.org/licenses/LICENSE-2.0
12 #
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
18 */}}
19
20 {{/*
21 dcaegen2-services-common.configMap:
22 This template produces Kubernetes configMap(s) needed by a
23 DCAE microservice.
24
25 The template expects the full chart context as input.  A chart for a
26 DCAE microservice references this template using:
27 {{ include "dcaegen2-services-common.configMap" . }}
28 The template directly references data in .Values, and indirectly (through its
29 use of templates from the ONAP "common" collection) references data in
30 .Release.
31
32 The template always produces a configMap containing the microservice's
33 initial configuration data.  This configMap is used by an initContainer
34 that loads the configuration into Consul.  (See the documentation for
35 dcaegen2-services-common.microserviceDeployment for more details.)
36
37 If the microservice is using a logging sidecar (again, see the documentation
38 for dcaegen2-services-common.microserviceDeployment for more details), the
39 template generates an additiona configMap that supplies configuration
40 information for the logging sidecar.
41 */}}
42
43 {{- define "dcaegen2-services-common.configMap" -}}
44 {{- $appConf := .Values.applicationConfig | default (dict) -}}
45 apiVersion: v1
46 kind: ConfigMap
47 metadata:
48     name: {{ include "common.fullname" . }}-application-config-configmap
49     namespace: {{ include "common.namespace" . }}
50     labels: {{ include "common.labels" . | nindent 6 }}
51 data:
52   application_config.yaml: |
53 {{ $appConf | toYaml | indent 4 }}
54
55 {{- if .Values.drFeedConfig }}
56 ---
57 apiVersion: v1
58 kind: ConfigMap
59 metadata:
60   name: {{ include "common.fullname" . }}-feeds-config
61   namespace: {{ include "common.namespace" . }}
62   labels: {{ include "common.labels" . | nindent 6 }}
63 data:
64   {{- range $i, $feed := .Values.drFeedConfig }}
65   feedConfig-{{$i}}.json: |-
66   {{ $feed | toJson | indent 2 }}
67   {{- end }}
68 {{- end }}
69
70 {{- if .Values.drPubConfig }}
71 ---
72 apiVersion: v1
73 kind: ConfigMap
74 metadata:
75   name: {{ include "common.fullname" . }}-drpub-config
76   namespace: {{ include "common.namespace" . }}
77   labels: {{ include "common.labels" . | nindent 6 }}
78 data:
79   {{- range $i, $drpub := .Values.drPubConfig }}
80   drpubConfig-{{$i}}.json: |-
81   {{ $drpub | toJson | indent 2 }}
82   {{- end }}
83 {{- end }}
84
85 {{- if .Values.drSubConfig }}
86 ---
87 apiVersion: v1
88 kind: ConfigMap
89 metadata:
90   name: {{ include "common.fullname" . }}-drsub-config
91   namespace: {{ include "common.namespace" . }}
92   labels: {{ include "common.labels" . | nindent 6 }}
93 data:
94   {{- range $i, $drsub := .Values.drSubConfig }}
95   drsubConfig-{{$i}}.json: |-
96   {{ $drsub | toJson | indent 2 }}
97   {{- end }}
98 {{- end }}
99
100 {{- if .Values.mrTopicsConfig }}
101 ---
102 apiVersion: v1
103 kind: ConfigMap
104 metadata:
105   name: {{ include "common.fullname" . }}-topics-config
106   namespace: {{ include "common.namespace" . }}
107   labels: {{ include "common.labels" . | nindent 6 }}
108 data:
109   {{- range $i, $topics := .Values.mrTopicsConfig }}
110   topicsConfig-{{$i}}.json: |-
111   {{ $topics | toJson | indent 2 }}
112   {{- end }}
113 {{- end }}
114 {{- end }}