apiVersion: v1
kind: Secret
metadata:
  name: redis-creds
  labels:
    app: drycc-redis
    heritage: drycc
  annotations:
    "helm.sh/hook": pre-install
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: {{ randAlphaNum 32 | b64enc }}
  {{ else if eq .Values.global.redisLocation "off-cluster"}}
  addrs: {{ .Values.addrs | b64enc }}
  password: {{ .Values.password | b64enc }}
  {{ end }}
