apiVersion: v1
kind: Secret
metadata:
  name: redis-creds
  labels:
    app: drycc-redis
    heritage: drycc
data: 
  {{ if eq .Values.global.redisLocation "on-cluster"}}
  {{- $redisAddrs := (list ) }}
  {{- $redisNodeCount := .Values.replicas | int }}
  {{- range $i := until $redisNodeCount }}
  {{- $redisAddrs = (append $redisAddrs (printf "drycc-redis-%d.drycc-redis.%s.svc.%s:6379" $i $.Release.Namespace $.Values.global.clusterDomain)) }}
  {{- end -}}
  addrs: {{ join "," $redisAddrs | b64enc }}
  password: {{ include "common.secrets.lookup" (dict "secret" "redis-creds" "key" "password" "defaultValue" (randAlphaNum 32) "context" $) }}
  {{ else if eq .Values.global.redisLocation "off-cluster"}}
  addrs: {{ .Values.addrs | b64enc }}
  password: {{ .Values.password | b64enc }}
  {{ end }}
