From bb13eed501884641e2c790c508b5cfc0b5c21e5f Mon Sep 17 00:00:00 2001
From: Oleksandr Kosse <oleksandr_kosse@epam.com>
Date: Sun, 19 Mar 2023 13:06:38 +0100
Subject: [PATCH] [GONRG-6649] Define global vars in indexer

---
 devops/gc/deploy/README.md                      | 9 +++++++--
 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 ++++--
 6 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/devops/gc/deploy/README.md b/devops/gc/deploy/README.md
index 17d79036d..e2d9e0b9c 100644
--- a/devops/gc/deploy/README.md
+++ b/devops/gc/deploy/README.md
@@ -25,6 +25,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.elasticSecretName** | secret for elastic | string | `indexer-elastic-secret` | yes
 **conf.keycloakSecretName** | secret for keycloak | string | `indexer-keycloak-secret` | yes
 **conf.rabbitmqSecretName** | secret for rabbitmq | string | `rabbitmq-secret` | yes
-**conf.onPremEnabled** | whether on-prem is enabled | boolean | false | yes
-**conf.domain** | your domain | string | - | yes
 **conf.indexerRedisSecretName** | indexer Redis secret that contains redis password with REDIS_PASSWORD key | string | `indexer-redis-secret` | yes
 
 ### ISTIO variables
diff --git a/devops/gc/deploy/templates/deployment.yaml b/devops/gc/deploy/templates/deployment.yaml
index cfd362ebc..e42da5931 100644
--- a/devops/gc/deploy/templates/deployment.yaml
+++ b/devops/gc/deploy/templates/deployment.yaml
@@ -41,7 +41,7 @@ spec:
             name: {{ .Values.conf.configmap | quote }}
         - secretRef:
             name: {{ .Values.conf.elasticSecretName | quote }}
-        {{- if .Values.conf.onPremEnabled }}
+        {{- if .Values.global.onPremEnabled }}
         - secretRef:
             name: {{ .Values.conf.keycloakSecretName | quote }}
         - secretRef:
diff --git a/devops/gc/deploy/templates/service-account.yaml b/devops/gc/deploy/templates/service-account.yaml
index f0771985c..eec72f128 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 45bd50538..f985dd5f7 100644
--- a/devops/gc/deploy/templates/service.yaml
+++ b/devops/gc/deploy/templates/service.yaml
@@ -1,7 +1,7 @@
 apiVersion: v1
 kind: Service
 metadata:
-  {{- if not .Values.conf.onPremEnabled }}
+  {{- if not .Values.global.onPremEnabled }}
   annotations:
     cloud.google.com/neg: '{"ingress": true}'
   {{- end }}
diff --git a/devops/gc/deploy/templates/virtual-service.yaml b/devops/gc/deploy/templates/virtual-service.yaml
index ed9507c97..8903b299b 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 b71731641..b657f2f62 100644
--- a/devops/gc/deploy/values.yaml
+++ b/devops/gc/deploy/values.yaml
@@ -2,6 +2,10 @@
 # This is a YAML-formatted file.
 # Declare variables to be passed into your templates.
 
+global:
+  domain: ""
+  onPremEnabled: false
+
 data:
   # Configmap
   entitlementsHost: "http://entitlements"
@@ -30,8 +34,6 @@ conf:
   elasticSecretName: "indexer-elastic-secret"
   keycloakSecretName: "indexer-keycloak-secret"
   rabbitmqSecretName: "rabbitmq-secret"
-  onPremEnabled: false
-  domain: ""
   indexerRedisSecretName: "indexer-redis-secret"
 
 istio:
-- 
GitLab