Skip to content

Commit

Permalink
search template helpers cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
alxgomz committed Sep 19, 2023
1 parent 3f5d6c3 commit 3d4eca2
Showing 1 changed file with 9 additions and 41 deletions.
50 changes: 9 additions & 41 deletions helm/alfresco-content-services/templates/_helpers-search.tpl
Original file line number Diff line number Diff line change
@@ -1,38 +1,5 @@
{{/*
Alfresco Repository index subsystem
*/}}
{{- define "repository.indexSubsystem" -}}
{{- if or (index .Values "alfresco-search" "enabled") (index .Values "alfresco-search" "external" "host") -}}
solr6
{{- else if index .Values "alfresco-search-enterprise" "enabled" -}}
elasticsearch
{{- else -}}
none
{{- end }}
{{- end -}}

{{/*
Alfresco Repository search configuration
*/}}
{{- define "repository.indexConfig" -}}
{{- if index .Values "alfresco-search" "external" "host" }}
-Dsolr.host={{ index .Values "alfresco-search" "external" "host" }}
-Dsolr.port={{ index .Values "alfresco-search" "external" "port" | default 8983 }}
-Dsolr.base.url={{ template "alfresco-search.baseurl" . }}
-Dsolr.secureComms={{ .Values.global.tracking.auth | default "secret" }}
{{- else if index .Values "alfresco-search" "enabled" -}}
{{- $alfrescoSearchContext := dict "Chart" $.Chart "Release" $.Release "Values" (index .Values "alfresco-search") }}
-Dsolr.host={{ template "alfresco-search.host" $alfrescoSearchContext }}
-Dsolr.port={{ template "alfresco-search.svcPort" $alfrescoSearchContext }}
-Dsolr.base.url={{ index .Values "alfresco-search" "ingress" "path" | default "/solr" }}
-Dsolr.secureComms={{ .Values.global.tracking.auth | default "secret" }}
{{- else if index .Values "alfresco-search-enterprise" "enabled" }}
{{- template "repo.elasticsearch.config" . }}
{{- end }}
{{- end -}}

{{/*
Compute the search URL
Set the search URL
Usage: include "alfresco-content-service.search.set.url" $
Expand All @@ -43,13 +10,11 @@ Usage: include "alfresco-content-service.search.set.url" $
{{- if and (index . "alfresco-search-enterprise" "enabled") (index . "alfresco-search-enterprise" "elasticsearch" "enabled") }}
{{- with (index . "alfresco-search-enterprise") }}
{{- $es_url := (printf "%s://%s-%s:%s" .elasticsearch.protocol .elasticsearch.clusterName .elasticsearch.nodeGroup .elasticsearch.httpPort) }}
{{- $_ := set $.Values.search "url" $es_url }}
{{- $_ := set .search "url" $es_url }}
{{- end }}
{{- else if (index . "alfresco-search" "enabled") }}
{{/* DEPRECATE use chart.fullname with built ctx instead */}}
{{- $_ := set $.Values.search "url" (printf "http://%s-%s" (include "alfresco-search-service.fullname" $) "solr") }}
{{- else }}
{{- fail "You must either set search.url, alfresco-search-enterprise.elasticsearch.enabled or alfresco-search.enabled" }}
{{- $_ := set .search "url" (printf "http://%s-%s/solr" (include "alfresco-search-service.fullname" $) "solr") }}
{{- end }}
{{- end }}
{{- end }}
Expand All @@ -62,14 +27,17 @@ Usage: include "alfresco-content-service.search.set.flavor" $
*/}}
{{- define "alfresco-content-service.search.set.flavor" -}}
{{- template "alfresco-content-service.search.set.url" $ }}
{{- with .Values }}
{{- if (not .search.flavor) }}
{{- if index . "alfresco-search-enterprise" "enabled" }}
{{- $_ := set $.Values.search "flavor" "elasticsearch" }}
{{- $_ := set .search "flavor" "elasticsearch" }}
{{- else if (index . "alfresco-search" "enabled") }}
{{- $_ := set $.Values.search "flavor" "solr6" }}
{{- $_ := set .search "flavor" "solr6" }}
{{- else if hasSuffix "/solr" (trimSuffix "/" .search.url) }}
{{- $_ := set .search "flavor" "solr6" }}
{{- else }}
{{- $_ := set $.Values.search "flavor" "noindex" }}
{{- $_ := set .search "flavor" "noindex" }}
{{- end }}
{{- end }}
{{- end }}
Expand Down

0 comments on commit 3d4eca2

Please sign in to comment.