From 9851d24c2a065f445ea51e09ec2414d5f09cddfe Mon Sep 17 00:00:00 2001
From: Lubomir Dolezal <lubomir.bucek@eox.at>
Date: Mon, 31 Jan 2022 19:36:50 +0100
Subject: [PATCH] fix default browse handling in initdb not sure if this ever
 worked before or just new helm version was failing, but this is a fix

---
 charts/vs-registrar/files/init-db.sh | 10 ++++++----
 charts/vs-renderer/files/init-db.sh  | 10 ++++++----
 2 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/charts/vs-registrar/files/init-db.sh b/charts/vs-registrar/files/init-db.sh
index dd880fb..035539e 100644
--- a/charts/vs-registrar/files/init-db.sh
+++ b/charts/vs-registrar/files/init-db.sh
@@ -106,12 +106,14 @@ if python3 manage.py id check {{ index (keys $.Values.global.collections | sortA
         {{ range $coverage_type_name, $coverage_type := $product_type.coverages }}--coverage-type {{ $coverage_type_name | quote }} \
         {{ end }}--traceback
 
-    {{- if hasKey $product_type "defaultBrowse" }}
-    {{ template "browsetype.cli" dict "product_type_name" $product_type.name "browse_type_name" nil "browse_type" (get $product_type.browses $product_type.defaultBrowse) }}
-    {{- end }}
-
     {{- range $browse_type_name, $browse_type := $product_type.browses }}
     {{ template "browsetype.cli" dict "product_type_name" $product_type.name "browse_type_name" $browse_type_name "browse_type" $browse_type }}
+    {{- if hasKey $product_type "defaultBrowse" }}
+    {{ $defaultBrowse := get $product_type "defaultBrowse"}}
+    {{- if eq $browse_type_name $defaultBrowse}}
+    {{ template "browsetype.cli" dict "product_type_name" $product_type.name "browse_type_name" "" "browse_type" $browse_type }}
+    {{- end }}
+    {{- end }}
     {{- end }}
 
     {{- range $mask_type := $product_type.masks }}
diff --git a/charts/vs-renderer/files/init-db.sh b/charts/vs-renderer/files/init-db.sh
index dd880fb..035539e 100644
--- a/charts/vs-renderer/files/init-db.sh
+++ b/charts/vs-renderer/files/init-db.sh
@@ -106,12 +106,14 @@ if python3 manage.py id check {{ index (keys $.Values.global.collections | sortA
         {{ range $coverage_type_name, $coverage_type := $product_type.coverages }}--coverage-type {{ $coverage_type_name | quote }} \
         {{ end }}--traceback
 
-    {{- if hasKey $product_type "defaultBrowse" }}
-    {{ template "browsetype.cli" dict "product_type_name" $product_type.name "browse_type_name" nil "browse_type" (get $product_type.browses $product_type.defaultBrowse) }}
-    {{- end }}
-
     {{- range $browse_type_name, $browse_type := $product_type.browses }}
     {{ template "browsetype.cli" dict "product_type_name" $product_type.name "browse_type_name" $browse_type_name "browse_type" $browse_type }}
+    {{- if hasKey $product_type "defaultBrowse" }}
+    {{ $defaultBrowse := get $product_type "defaultBrowse"}}
+    {{- if eq $browse_type_name $defaultBrowse}}
+    {{ template "browsetype.cli" dict "product_type_name" $product_type.name "browse_type_name" "" "browse_type" $browse_type }}
+    {{- end }}
+    {{- end }}
     {{- end }}
 
     {{- range $mask_type := $product_type.masks }}
-- 
GitLab