Skip to content

Commit

Permalink
AP-4499: extract conditional redis host name to _helpers
Browse files Browse the repository at this point in the history
Decomplicate the `_envs` file and allows commenting
on reason for conditional logic.
  • Loading branch information
jsugarman committed Oct 18, 2023
1 parent c78a005 commit 869ce27
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
6 changes: 1 addition & 5 deletions helm_deploy/apply-for-legal-aid/templates/_envs.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,7 @@ env:
- name: REDIS_PROTOCOL
value: "redis"
- name: REDIS_HOST
{{ if contains "redis" .Release.Name }}
value: {{ printf "%s-master.%s.svc.cluster.local" .Release.Name .Release.Namespace }}
{{ else }}
value: {{ printf "%s-redis-master.%s.svc.cluster.local" .Release.Name .Release.Namespace }}
{{ end }}
value: {{ template "apply-for-legal-aid.redis-uat-host" . }}
- name: REDIS_PASSWORD
valueFrom:
secretKeyRef:
Expand Down
17 changes: 17 additions & 0 deletions helm_deploy/apply-for-legal-aid/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,20 @@ https://pauladamsmith.com/blog/2011/05/go_time.html
{{ "* * * * *" }}
{{- end -}}
{{- end -}}

{{/*
Function to return the name for a UAT redis chart master node host
This duplicates bitnami/redis chart's internal logic whereby
If branch name contains "redis" then the redis-release-name appends "-master", otherwise it appends "-redis-master"
*/}}
{{- define "apply-for-legal-aid.redis-uat-host" -}}
{{- $redis_chart_name := "redis" -}}
{{- if contains $redis_chart_name .Release.Name -}}
{{- $redis_release_name := (.Release.Name | trunc 63 | trimSuffix "-") -}}
{{- printf "%s-master.%s.svc.cluster.local" $redis_release_name .Release.Namespace -}}
{{- else -}}
{{- $redis_release_name := (printf "%s-%s" .Release.Name $redis_chart_name | trunc 63 | trimSuffix "-") -}}
{{- printf "%s-master.%s.svc.cluster.local" $redis_release_name .Release.Namespace -}}
{{- end -}}
{{- end -}}

0 comments on commit 869ce27

Please sign in to comment.