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

---
 devops/gc/deploy/README.md                           | 9 +++++++--
 devops/gc/deploy/templates/bootstrap-configmap.yaml  | 2 +-
 devops/gc/deploy/templates/bootstrap-deployment.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 ++++--
 8 files changed, 20 insertions(+), 13 deletions(-)

diff --git a/devops/gc/deploy/README.md b/devops/gc/deploy/README.md
index dba30bc19..98ce0c39f 100644
--- a/devops/gc/deploy/README.md
+++ b/devops/gc/deploy/README.md
@@ -26,6 +26,13 @@ Packages are only needed for installation from a local computer.
 
 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 |
@@ -73,9 +80,7 @@ First you need to set variables in **values.yaml** file using any code editor. S
 **conf.storageRedisSecretName** | secret for redis that contains redis password with REDIS_PASSWORD key | string | `storage-redis-secret` | yes
 **conf.bootstrapSecretName** | secret for bootstrap to access openid provider | string | `datafier-secret` | only if `conf.bootstrapEnabled` is true
 **conf.replicas** | Number of replicas | integer | 3 | yes
-**conf.onPremEnabled** | whether on-prem is enabled | boolean | false | yes
 **conf.bootstrapEnabled** | whether storage bootstrap is enabled | boolean | false | yes
-**conf.domain** | your domain, ex `example.com` | string | - | yes
 
 ### Istio variables
 
diff --git a/devops/gc/deploy/templates/bootstrap-configmap.yaml b/devops/gc/deploy/templates/bootstrap-configmap.yaml
index f4cf7f0a3..337f5c345 100644
--- a/devops/gc/deploy/templates/bootstrap-configmap.yaml
+++ b/devops/gc/deploy/templates/bootstrap-configmap.yaml
@@ -10,5 +10,5 @@ data:
   STORAGE_HOST: {{ .Values.data.storageHost | quote }}
   DEFAULT_LEGAL_TAG: {{ .Values.data.defaultLegalTag | quote }}
   DATA_PARTITION_ID: {{ .Values.data.dataPartitionId | quote }}
-  ONPREM_ENABLED: {{ .Values.conf.onPremEnabled | quote }}
+  ONPREM_ENABLED: {{ .Values.global.onPremEnabled | quote }}
 {{- end }}
diff --git a/devops/gc/deploy/templates/bootstrap-deployment.yaml b/devops/gc/deploy/templates/bootstrap-deployment.yaml
index 31999cee9..509f93d3d 100644
--- a/devops/gc/deploy/templates/bootstrap-deployment.yaml
+++ b/devops/gc/deploy/templates/bootstrap-deployment.yaml
@@ -34,7 +34,7 @@ spec:
           envFrom:
           - configMapRef:
               name: {{ printf "%s-config-bootstrap" .Values.conf.appName | quote }}
-          {{- if .Values.conf.onPremEnabled }}
+          {{- if .Values.global.onPremEnabled }}
           - secretRef:
               name: {{ .Values.conf.bootstrapSecretName | quote }}
           {{- end }}
diff --git a/devops/gc/deploy/templates/deployment.yaml b/devops/gc/deploy/templates/deployment.yaml
index 48e96b1ce..2f746f6ca 100644
--- a/devops/gc/deploy/templates/deployment.yaml
+++ b/devops/gc/deploy/templates/deployment.yaml
@@ -39,7 +39,7 @@ spec:
         envFrom:
         - configMapRef:
             name: {{ printf "%s-config" .Values.conf.appName | 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 4bf9d0e65..0e589c820 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 6b105c7d2..2d78e36ed 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:
   # configmaps
   logLevel: "ERROR"
@@ -40,9 +44,7 @@ conf:
   rabbitmqSecretName: "rabbitmq-secret"
   bootstrapSecretName: "datafier-secret"
   replicas: 3
-  onPremEnabled: false
   bootstrapEnabled: false
-  domain: ""
   storageRedisSecretName: "storage-redis-secret"
 
 istio:
-- 
GitLab