From d49d799c9d6b53e0f8d28726d28f748c418c139f Mon Sep 17 00:00:00 2001
From: Oleksandr Kosse <oleksandr_kosse@epam.com>
Date: Sun, 19 Mar 2023 14:03:12 +0100
Subject: [PATCH] [GONRG-6649] Define global vars in notification

---
 devops/gc/deploy/README.md                      | 9 +++++++--
 devops/gc/deploy/templates/configmap.yaml       | 2 +-
 devops/gc/deploy/templates/deployment.yaml      | 2 +-
 devops/gc/deploy/templates/service-account.yaml | 2 +-
 devops/gc/deploy/templates/service.yaml         | 2 +-
 devops/gc/deploy/templates/virtual-service.yaml | 8 ++++----
 devops/gc/deploy/values.yaml                    | 6 ++++--
 7 files changed, 19 insertions(+), 12 deletions(-)

diff --git a/devops/gc/deploy/README.md b/devops/gc/deploy/README.md
index 9b7a29226..6ac2f31db 100644
--- a/devops/gc/deploy/README.md
+++ b/devops/gc/deploy/README.md
@@ -27,6 +27,13 @@ Packages are only needed for installation from a local computer.
 Before installing deploy Helm chart you need to install [configmap Helm chart](../configmap).
 First you need to set variables in **values.yaml** file using any code editor. Some of the values are prefilled, but you need to specify some values as well. You can find more information about them below.
 
+### Global variables
+
+| Name | Description | Type | Default |Required |
+|------|-------------|------|---------|---------|
+**global.domain** | your domain for the external endpoint, ex `example.com` | string | - | yes
+**global.onPremEnabled** | whether on-prem is enabled | boolean | false | yes
+
 ### Configmap variables
 
 | Name | Description | Type | Default |Required |
@@ -61,8 +68,6 @@ First you need to set variables in **values.yaml** file using any code editor. S
 **conf.rabbitmqSecretName** | secret for rabbitmq | string | `rabbitmq-secret` | yes
 **conf.openidSecretName** | secret for openid | string | `notification-keycloak-secret` | yes
 **conf.notificationRedisSecretName** | Notification redis secret | string | `notification-redis-secret` | yes
-**conf.onPremEnabled** | whether on-prem is enabled | boolean | false | yes
-**conf.domain** | your domain, ex `example.com` | string | - | yes
 **conf.redisSSL** | Redis  host ssl config. External redis configuration only if true | string | false | no
 
 ### Istio variables
diff --git a/devops/gc/deploy/templates/configmap.yaml b/devops/gc/deploy/templates/configmap.yaml
index 67c3981f3..ce5da3ac6 100644
--- a/devops/gc/deploy/templates/configmap.yaml
+++ b/devops/gc/deploy/templates/configmap.yaml
@@ -18,5 +18,5 @@ data:
   {{- else }}
   REDIS_HOST: {{ printf "redis-%s" .Values.conf.appName | quote }}
   {{- end }}
-  {{- if not .Values.conf.onPremEnabled }}
+  {{- if not .Values.global.onPremEnabled }}
   {{- end }}
diff --git a/devops/gc/deploy/templates/deployment.yaml b/devops/gc/deploy/templates/deployment.yaml
index 40c4a8eb5..a2700e076 100644
--- a/devops/gc/deploy/templates/deployment.yaml
+++ b/devops/gc/deploy/templates/deployment.yaml
@@ -30,7 +30,7 @@ spec:
               name: {{ .Values.conf.configmap  | quote}}
           - secretRef:
               name: {{ .Values.conf.notificationRedisSecretName | quote }}
-          {{- if .Values.conf.onPremEnabled }}
+          {{- if .Values.global.onPremEnabled }}
           - secretRef:
               name: {{ .Values.conf.rabbitmqSecretName  | quote}}
           - secretRef:
diff --git a/devops/gc/deploy/templates/service-account.yaml b/devops/gc/deploy/templates/service-account.yaml
index 0c19fb197..82d89c345 100644
--- a/devops/gc/deploy/templates/service-account.yaml
+++ b/devops/gc/deploy/templates/service-account.yaml
@@ -1,4 +1,4 @@
-{{- if .Values.conf.onPremEnabled }}
+{{- if .Values.global.onPremEnabled }}
 apiVersion: v1
 kind: ServiceAccount
 metadata:
diff --git a/devops/gc/deploy/templates/service.yaml b/devops/gc/deploy/templates/service.yaml
index 26a5e52c0..57ef355de 100644
--- a/devops/gc/deploy/templates/service.yaml
+++ b/devops/gc/deploy/templates/service.yaml
@@ -3,7 +3,7 @@ kind: Service
 metadata:
   name: {{ .Values.conf.appName  | quote}}
   annotations:
-  {{- if not .Values.conf.onPremEnabled }}
+  {{- if not .Values.global.onPremEnabled }}
     cloud.google.com/neg: '{"ingress": true}'
   {{- end }}
   namespace: {{ .Release.Namespace  | quote}}
diff --git a/devops/gc/deploy/templates/virtual-service.yaml b/devops/gc/deploy/templates/virtual-service.yaml
index 9d0f13aac..7b28c5a48 100644
--- a/devops/gc/deploy/templates/virtual-service.yaml
+++ b/devops/gc/deploy/templates/virtual-service.yaml
@@ -5,10 +5,10 @@ metadata:
   namespace: {{ .Release.Namespace  | quote}}
 spec:
   hosts:
-    {{- if and .Values.conf.domain .Values.conf.onPremEnabled }}
-    - {{ printf "osdu.%s" .Values.conf.domain | quote }}
-    {{- else if .Values.conf.domain }}
-    - {{ .Values.conf.domain | quote }}
+    {{- if and .Values.global.domain .Values.global.onPremEnabled }}
+    - {{ printf "osdu.%s" .Values.global.domain | quote }}
+    {{- else if .Values.global.domain }}
+    - {{ .Values.global.domain | quote }}
     {{- else }}
     - "*"
     {{- end }}
diff --git a/devops/gc/deploy/values.yaml b/devops/gc/deploy/values.yaml
index 4a1ba3021..bd781e857 100644
--- a/devops/gc/deploy/values.yaml
+++ b/devops/gc/deploy/values.yaml
@@ -1,3 +1,7 @@
+global:
+  domain: ""
+  onPremEnabled: false
+
 data:
   #Configmaps
   logLevel: "ERROR"
@@ -24,8 +28,6 @@ conf:
   rabbitmqSecretName: "rabbitmq-secret"
   openidSecretName: "notification-keycloak-secret"
   notificationRedisSecretName: "notification-redis-secret"
-  onPremEnabled: false
-  domain: ""
   redisSSL: false
 
 istio:
-- 
GitLab