Skip to content

Commit

Permalink
invenio: merge base config and extraConfig
Browse files Browse the repository at this point in the history
* Adds annotation to force pod recreation in case of changes
  (addresses inveniosoftware#142).
  • Loading branch information
egabancho committed Dec 17, 2024
1 parent c6d4708 commit 35649d4
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 22 deletions.
33 changes: 33 additions & 0 deletions charts/invenio/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -299,3 +299,36 @@ Add sentry environmental variables
key: {{ .Values.invenio.sentry.secretKeys.dsnKey }}
{{- end }}
{{- end -}}
{{/*
Invenio basic configuration variables
*/}}
{{- define "invenio.configBase" -}}
INVENIO_ACCOUNTS_SESSION_REDIS_URL: 'redis://{{ include "invenio.redis.hostname" . }}:6379/1'
INVENIO_APP_ALLOWED_HOSTS: '["{{ include "invenio.hostname" $ }}"]'
INVENIO_CACHE_REDIS_HOST: '{{ include "invenio.redis.hostname" . }}'
INVENIO_CACHE_REDIS_URL: 'redis://{{ include "invenio.redis.hostname" . }}:6379/0'
INVENIO_CELERY_RESULT_BACKEND: 'redis://{{ include "invenio.redis.hostname" . }}:6379/2'
INVENIO_IIIF_CACHE_REDIS_URL: 'redis://{{ include "invenio.redis.hostname" . }}:6379/0'
INVENIO_RATELIMIT_STORAGE_URI: 'redis://{{ include "invenio.redis.hostname" . }}:6379/3'
INVENIO_COMMUNITIES_IDENTITIES_CACHE_REDIS_URL: 'redis://{{ include "invenio.redis.hostname" . }}:6379/4'
INVENIO_SEARCH_HOSTS: {{ printf "[{'host': '%s'}]" (include "invenio.opensearch.hostname" .) | quote }}
INVENIO_SITE_HOSTNAME: '{{ include "invenio.hostname" $ }}'
INVENIO_SITE_UI_URL: 'https://{{ include "invenio.hostname" $ }}'
INVENIO_SITE_API_URL: 'https://{{ include "invenio.hostname" $ }}/api'
INVENIO_DATACITE_ENABLED: "False"
INVENIO_LOGGING_CONSOLE_LEVEL: "WARNING"
{{- end -}}

{{/*
Merge invenio.extraConfig and configBase using mergeOverwrite and rendering templates.
invenio.ExtraConfig will overwrite the values from configBase in case of duplicates.
*/}}
{{- define "invenio.mergeConfig" -}}
{{- $dst := dict -}}
{{- $values := list (include "invenio.configBase" .) (.Values.invenio.extra_config | toYaml) (.Values.invenio.extraConfig | toYaml) -}}
{{- range $values -}}
{{- $dst = tpl . $ | fromYaml | mergeOverwrite $dst -}}
{{- end -}}
{{- $dst | toYaml -}}
{{- end -}}
23 changes: 1 addition & 22 deletions charts/invenio/templates/invenio-configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,4 @@ metadata:
labels:
{{- include "invenio.labels" . | nindent 4 }}
data:
INVENIO_ACCOUNTS_SESSION_REDIS_URL: 'redis://{{ include "invenio.redis.hostname" . }}:6379/1'
INVENIO_APP_ALLOWED_HOSTS: '["{{ include "invenio.hostname" $ }}"]'
INVENIO_CACHE_REDIS_HOST: '{{ include "invenio.redis.hostname" . }}'
INVENIO_CACHE_REDIS_URL: 'redis://{{ include "invenio.redis.hostname" . }}:6379/0'
INVENIO_CELERY_RESULT_BACKEND: 'redis://{{ include "invenio.redis.hostname" . }}:6379/2'
INVENIO_IIIF_CACHE_REDIS_URL: 'redis://{{ include "invenio.redis.hostname" . }}:6379/0'
INVENIO_RATELIMIT_STORAGE_URI: 'redis://{{ include "invenio.redis.hostname" . }}:6379/3'
INVENIO_COMMUNITIES_IDENTITIES_CACHE_REDIS_URL: 'redis://{{ include "invenio.redis.hostname" . }}:6379/4'
{{- if not (hasKey .Values.invenio.extra_config "INVENIO_SEARCH_HOSTS") }}
INVENIO_SEARCH_HOSTS: {{ printf "[{'host': '%s'}]" (include "invenio.opensearch.hostname" .) | quote }}
{{- end }}
INVENIO_SITE_HOSTNAME: '{{ include "invenio.hostname" $ }}'
INVENIO_SITE_UI_URL: 'https://{{ include "invenio.hostname" $ }}'
INVENIO_SITE_API_URL: 'https://{{ include "invenio.hostname" $ }}/api'
INVENIO_DATACITE_ENABLED: "False"
INVENIO_LOGGING_CONSOLE_LEVEL: "WARNING"
{{- range $key, $value := .Values.invenio.extra_config }}
{{ $key }}: {{ $value | toYaml | indent 4 | trim }}
{{- end }}
{{- range $key, $value := .Values.invenio.extraConfig }}
{{ $key }}: {{ tpl $value $ | toYaml | indent 4 | trim }}
{{- end }}
{{- include "invenio.mergeConfig" . | nindent 2 -}}

0 comments on commit 35649d4

Please sign in to comment.