[ESR] Uses new tpls for repos / images

This commit makes ESR chart to use the new generator for repositories and
images.
As new templates doesn't work well with "sub charts", we move also
subcharts to components folder.

Issue-ID: OOM-2364
Signed-off-by: Sylvain Desbureaux <sylvain.desbureaux@orange.com>
Change-Id: Icd413c31a4f11116084d04fcf0c8984929f5f17d
diff --git a/kubernetes/esr/Makefile b/kubernetes/esr/Makefile
new file mode 100644
index 0000000..4c79718
--- /dev/null
+++ b/kubernetes/esr/Makefile
@@ -0,0 +1,51 @@
+# Copyright © 2020 Samsung Electronics
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+ROOT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
+OUTPUT_DIR := $(ROOT_DIR)/../dist
+PACKAGE_DIR := $(OUTPUT_DIR)/packages
+SECRET_DIR := $(OUTPUT_DIR)/secrets
+
+EXCLUDES := dist resources templates charts docker
+HELM_BIN := helm
+HELM_CHARTS := $(filter-out $(EXCLUDES), $(sort $(patsubst %/.,%,$(wildcard */.))))
+
+.PHONY: $(EXCLUDES) $(HELM_CHARTS)
+
+all: $(HELM_CHARTS)
+
+$(HELM_CHARTS):
+	@echo "\n[$@]"
+	@make package-$@
+
+make-%:
+	@if [ -f $*/Makefile ]; then make -C $*; fi
+
+dep-%: make-%
+	@if [ -f $*/requirements.yaml ]; then $(HELM_BIN) dep up $*; fi
+
+lint-%: dep-%
+	@if [ -f $*/Chart.yaml ]; then $(HELM_BIN) lint $*; fi
+
+package-%: lint-%
+	@mkdir -p $(PACKAGE_DIR)
+	@if [ -f $*/Chart.yaml ]; then $(HELM_BIN) package -d $(PACKAGE_DIR) $*; fi
+	@$(HELM_BIN) repo index $(PACKAGE_DIR)
+
+clean:
+	@rm -f */requirements.lock
+	@rm -f *tgz */charts/*tgz
+	@rm -rf $(PACKAGE_DIR)
+%:
+	@:
diff --git a/kubernetes/esr/components/Makefile b/kubernetes/esr/components/Makefile
new file mode 100644
index 0000000..bf267b7
--- /dev/null
+++ b/kubernetes/esr/components/Makefile
@@ -0,0 +1,51 @@
+# Copyright © 2020 Samsung Electronics
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+ROOT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
+OUTPUT_DIR := $(ROOT_DIR)/../../dist
+PACKAGE_DIR := $(OUTPUT_DIR)/packages
+SECRET_DIR := $(OUTPUT_DIR)/secrets
+
+EXCLUDES :=
+HELM_BIN := helm
+HELM_CHARTS := $(filter-out $(EXCLUDES), $(sort $(patsubst %/.,%,$(wildcard */.))))
+
+.PHONY: $(EXCLUDES) $(HELM_CHARTS)
+
+all: $(HELM_CHARTS)
+
+$(HELM_CHARTS):
+	@echo "\n[$@]"
+	@make package-$@
+
+make-%:
+	@if [ -f $*/Makefile ]; then make -C $*; fi
+
+dep-%: make-%
+	@if [ -f $*/requirements.yaml ]; then $(HELM_BIN) dep up $*; fi
+
+lint-%: dep-%
+	@if [ -f $*/Chart.yaml ]; then $(HELM_BIN) lint $*; fi
+
+package-%: lint-%
+	@mkdir -p $(PACKAGE_DIR)
+	@if [ -f $*/Chart.yaml ]; then $(HELM_BIN) package -d $(PACKAGE_DIR) $*; fi
+	@$(HELM_BIN) repo index $(PACKAGE_DIR)
+
+clean:
+	@rm -f */requirements.lock
+	@rm -f *tgz */charts/*tgz
+	@rm -rf $(PACKAGE_DIR)
+%:
+	@:
diff --git a/kubernetes/esr/charts/esr-gui/.helmignore b/kubernetes/esr/components/esr-gui/.helmignore
similarity index 100%
rename from kubernetes/esr/charts/esr-gui/.helmignore
rename to kubernetes/esr/components/esr-gui/.helmignore
diff --git a/kubernetes/esr/charts/esr-gui/Chart.yaml b/kubernetes/esr/components/esr-gui/Chart.yaml
similarity index 100%
rename from kubernetes/esr/charts/esr-gui/Chart.yaml
rename to kubernetes/esr/components/esr-gui/Chart.yaml
diff --git a/kubernetes/esr/charts/esr-server/requirements.yaml b/kubernetes/esr/components/esr-gui/requirements.yaml
similarity index 83%
rename from kubernetes/esr/charts/esr-server/requirements.yaml
rename to kubernetes/esr/components/esr-gui/requirements.yaml
index a999e38..0b77abe 100644
--- a/kubernetes/esr/charts/esr-server/requirements.yaml
+++ b/kubernetes/esr/components/esr-gui/requirements.yaml
@@ -1,4 +1,5 @@
-# Copyright © 2018 Amdocs, Bell Canada
+# Copyright © 2017 Amdocs, Bell Canada
+# Modifications Copyright © 2018 AT&T
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -18,4 +19,7 @@
     # local reference to common chart, as it is
     # a part of this chart's package and will not
     # be published independently to a repo (at this point)
-    repository: '@local'
\ No newline at end of file
+    repository: '@local'
+  - name: repositoryGenerator
+    version: ~6.x-0
+    repository: '@local'
diff --git a/kubernetes/esr/charts/esr-gui/templates/NOTES.txt b/kubernetes/esr/components/esr-gui/templates/NOTES.txt
similarity index 100%
rename from kubernetes/esr/charts/esr-gui/templates/NOTES.txt
rename to kubernetes/esr/components/esr-gui/templates/NOTES.txt
diff --git a/kubernetes/esr/charts/esr-gui/templates/deployment.yaml b/kubernetes/esr/components/esr-gui/templates/deployment.yaml
similarity index 94%
rename from kubernetes/esr/charts/esr-gui/templates/deployment.yaml
rename to kubernetes/esr/components/esr-gui/templates/deployment.yaml
index 985f4a1..74f9335 100644
--- a/kubernetes/esr/charts/esr-gui/templates/deployment.yaml
+++ b/kubernetes/esr/components/esr-gui/templates/deployment.yaml
@@ -50,7 +50,7 @@
         - /opt/tomcat
         securityContext:
           privileged: true
-        image: "{{ include "common.repository" . }}/{{ .Values.image }}"
+        image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.image }}
         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
         name: create-tomcat-dir
         volumeMounts:
@@ -59,7 +59,7 @@
 
       containers:
         - name: {{ include "common.name" . }}
-          image: "{{ include "common.repository" . }}/{{ .Values.image }}"
+          image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.image }}
           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
           ports:
           - containerPort: {{ .Values.service.internalPort }}
diff --git a/kubernetes/esr/charts/esr-gui/templates/service.yaml b/kubernetes/esr/components/esr-gui/templates/service.yaml
similarity index 100%
rename from kubernetes/esr/charts/esr-gui/templates/service.yaml
rename to kubernetes/esr/components/esr-gui/templates/service.yaml
diff --git a/kubernetes/esr/charts/esr-gui/values.yaml b/kubernetes/esr/components/esr-gui/values.yaml
similarity index 98%
rename from kubernetes/esr/charts/esr-gui/values.yaml
rename to kubernetes/esr/components/esr-gui/values.yaml
index a191739..417ace5 100644
--- a/kubernetes/esr/charts/esr-gui/values.yaml
+++ b/kubernetes/esr/components/esr-gui/values.yaml
@@ -23,7 +23,6 @@
 # Application configuration defaults.
 #################################################################
 # application image
-repository: nexus3.onap.org:10001
 image: onap/aai/esr-gui:1.4.0
 pullPolicy: Always
 msbaddr: msb-iag.{{ include "common.namespace" . }}:443
diff --git a/kubernetes/esr/charts/esr-server/Chart.yaml b/kubernetes/esr/components/esr-server/Chart.yaml
similarity index 100%
rename from kubernetes/esr/charts/esr-server/Chart.yaml
rename to kubernetes/esr/components/esr-server/Chart.yaml
diff --git a/kubernetes/esr/charts/esr-server/requirements.yaml b/kubernetes/esr/components/esr-server/requirements.yaml
similarity index 83%
copy from kubernetes/esr/charts/esr-server/requirements.yaml
copy to kubernetes/esr/components/esr-server/requirements.yaml
index a999e38..0b77abe 100644
--- a/kubernetes/esr/charts/esr-server/requirements.yaml
+++ b/kubernetes/esr/components/esr-server/requirements.yaml
@@ -1,4 +1,5 @@
-# Copyright © 2018 Amdocs, Bell Canada
+# Copyright © 2017 Amdocs, Bell Canada
+# Modifications Copyright © 2018 AT&T
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -18,4 +19,7 @@
     # local reference to common chart, as it is
     # a part of this chart's package and will not
     # be published independently to a repo (at this point)
-    repository: '@local'
\ No newline at end of file
+    repository: '@local'
+  - name: repositoryGenerator
+    version: ~6.x-0
+    repository: '@local'
diff --git a/kubernetes/esr/charts/esr-server/resources/config/log/filebeat/filebeat.yml b/kubernetes/esr/components/esr-server/resources/config/log/filebeat/filebeat.yml
similarity index 100%
rename from kubernetes/esr/charts/esr-server/resources/config/log/filebeat/filebeat.yml
rename to kubernetes/esr/components/esr-server/resources/config/log/filebeat/filebeat.yml
diff --git a/kubernetes/esr/charts/esr-server/resources/config/logback.xml b/kubernetes/esr/components/esr-server/resources/config/logback.xml
similarity index 100%
rename from kubernetes/esr/charts/esr-server/resources/config/logback.xml
rename to kubernetes/esr/components/esr-server/resources/config/logback.xml
diff --git a/kubernetes/esr/charts/esr-server/templates/NOTES.txt b/kubernetes/esr/components/esr-server/templates/NOTES.txt
similarity index 100%
rename from kubernetes/esr/charts/esr-server/templates/NOTES.txt
rename to kubernetes/esr/components/esr-server/templates/NOTES.txt
diff --git a/kubernetes/esr/charts/esr-server/templates/configmap.yaml b/kubernetes/esr/components/esr-server/templates/configmap.yaml
similarity index 100%
rename from kubernetes/esr/charts/esr-server/templates/configmap.yaml
rename to kubernetes/esr/components/esr-server/templates/configmap.yaml
diff --git a/kubernetes/esr/charts/esr-server/templates/deployment.yaml b/kubernetes/esr/components/esr-server/templates/deployment.yaml
similarity index 95%
rename from kubernetes/esr/charts/esr-server/templates/deployment.yaml
rename to kubernetes/esr/components/esr-server/templates/deployment.yaml
index e8dd5cd..03bcaa0 100644
--- a/kubernetes/esr/charts/esr-server/templates/deployment.yaml
+++ b/kubernetes/esr/components/esr-server/templates/deployment.yaml
@@ -50,7 +50,7 @@
         - /opt/conf
         securityContext:
           privileged: true
-        image: "{{ include "common.repository" . }}/{{ .Values.image }}"
+        image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.image }}
         imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
         name: create-conf-dir
         volumeMounts:
@@ -59,7 +59,7 @@
 
       containers:
         - name: {{ .Chart.Name }}
-          image: "{{ include "common.repository" . }}/{{ .Values.image }}"
+          image: {{ include "repositoryGenerator.repository" . }}/{{ .Values.image }}
           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
           ports:
           - containerPort: {{ .Values.service.internalPort }}
@@ -103,7 +103,7 @@
           securityContext:
             runAsUser: 1000
             runAsGroup: 1000
-          image: "{{ .Values.global.loggingRepository }}/{{ .Values.global.loggingImage }}"
+          image: {{ include "repositoryGenerator.image.logging" . }}
           imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
           volumeMounts:
           - name: {{ include "common.fullname" . }}-filebeat-conf
diff --git a/kubernetes/esr/charts/esr-server/templates/service.yaml b/kubernetes/esr/components/esr-server/templates/service.yaml
similarity index 100%
rename from kubernetes/esr/charts/esr-server/templates/service.yaml
rename to kubernetes/esr/components/esr-server/templates/service.yaml
diff --git a/kubernetes/esr/charts/esr-server/values.yaml b/kubernetes/esr/components/esr-server/values.yaml
similarity index 93%
rename from kubernetes/esr/charts/esr-server/values.yaml
rename to kubernetes/esr/components/esr-server/values.yaml
index 0177690..a3fb686 100644
--- a/kubernetes/esr/charts/esr-server/values.yaml
+++ b/kubernetes/esr/components/esr-server/values.yaml
@@ -17,15 +17,11 @@
 #################################################################
 global:
   nodePortPrefix: 302
-  readinessImage: onap/oom/readiness:3.0.1
-  loggingRepository: docker.elastic.co
-  loggingImage: beats/filebeat:5.5.0
 
 subChartsOnly:
   enabled: true
 
 # application image
-repository: nexus3.onap.org:10001
 image: onap/aai/esr-server:1.5.2
 pullPolicy: Always
 msbaddr: msb-iag.{{ include "common.namespace" . }}:443
diff --git a/kubernetes/esr/requirements.yaml b/kubernetes/esr/requirements.yaml
index d3c442d..8c2a82d 100644
--- a/kubernetes/esr/requirements.yaml
+++ b/kubernetes/esr/requirements.yaml
@@ -14,9 +14,10 @@
 # limitations under the License.
 
 dependencies:
-  - name: common
+  - name: esr-gui
     version: ~6.x-0
-    # local reference to common chart, as it is
-    # a part of this chart's package and will not
-    # be published independently to a repo (at this point)
-    repository: '@local'
+    repository: 'file://components/esr-gui'
+    condition: esr-gui.enabled
+  - name: esr-server
+    version: ~6.x-0
+    repository: 'file://components/esr-server'
diff --git a/kubernetes/esr/resources/config/log/esrserver/logback.xml b/kubernetes/esr/resources/config/log/esrserver/logback.xml
deleted file mode 100644
index b9a51f1..0000000
--- a/kubernetes/esr/resources/config/log/esrserver/logback.xml
+++ /dev/null
@@ -1,44 +0,0 @@
-<?xml version = "1.0" encoding = "UTF-8" ?>
-<!--
-# Copyright © 2018  AT&T, Amdocs, Bell Canada Intellectual Property.  All rights reserved.
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#       http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
--->
-
-<?xml version="1.0" encoding="UTF-8"?>
-<configuration debug="true" scan="true" scanPeriod="3 seconds">
-   <!--<jmxConfigurator /> -->
-   <!--  specify the base path of the log directory -->
-   <property name="logDir" value="/var/log/onap" />
-   <!--  specify the component name -->
-   <property name="componentName" value="esr" />
-   <!-- specify the sub component name -->
-   <property name="subComponentName" value="xacml-pap-rest" />
-   <!-- The directories where logs are written -->
-   <property name="logDirectory" value="${logDir}/${componentName}/${subComponentName}" />
-   <property name="pattern" value="%d{&amp;quot;yyyy-MM-dd'T'HH:mm:ss.SSSXXX&amp;quot;, UTC}\t[%thread]\t%-5level\t%logger{36}\t%replace(%replace(%replace(%mdc){'\t','\\\\t'}){', ','\t'}){'\n', '\\\\n'}\t%replace(%replace(%msg){'\n', '\\\\n'}){'\t','\\\\t'}%n" />
-   <!--  log file names -->
-   <property name="errorLogName" value="error" />
-   <property name="metricsLogName" value="metrics" />
-   <property name="auditLogName" value="audit" />
-   <property name="debugLogName" value="debug" />
-   <property name="queueSize" value="256" />
-   <property name="maxFileSize" value="50MB" />
-   <property name="maxHistory" value="30" />
-   <property name="totalSizeCap" value="10GB" />
-   <!-- Example evaluator filter applied against console appender -->
-   <appender class="ch.qos.logback.core.ConsoleAppender" name="STDOUT">
-      <encoder>
-         <pattern>${pattern}</pattern>
-      </encoder>
-   </appender>
diff --git a/kubernetes/esr/values.yaml b/kubernetes/esr/values.yaml
index bd12358..5b2f776 100644
--- a/kubernetes/esr/values.yaml
+++ b/kubernetes/esr/values.yaml
@@ -16,11 +16,11 @@
 #################################################################
 # Global configuration defaults.
 #################################################################
-global:
-  loggingRepository: docker.elastic.co
-  loggingImage: beats/filebeat:5.5.0
 
 # application configuration
 config:
   logstashServiceName: log-ls
-  logstashPort: 5044
\ No newline at end of file
+  logstashPort: 5044
+
+esr-gui:
+  enabled: true
\ No newline at end of file