|
| 1 | +{{/* vim: set filetype=mustache: */}} |
| 2 | + |
| 3 | +{{/* |
| 4 | +Create a default fully qualified app name. |
| 5 | +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). |
| 6 | +*/}} |
| 7 | +{{- define "function.redis.fullname" -}} |
| 8 | +{{- include "common.names.dependency.fullname" (dict "chartName" "redis" "chartValues" .Values.redis "context" $) -}} |
| 9 | +{{- end -}} |
| 10 | + |
| 11 | +{{/* |
| 12 | +Return the proper YOURLS image name |
| 13 | +*/}} |
| 14 | +{{- define "function.image" -}} |
| 15 | +{{- $imageRoot := .Values.image -}} |
| 16 | +{{- if not .Values.image.tag }} |
| 17 | + {{- $tag := (dict "tag" .Chart.AppVersion) -}} |
| 18 | + {{- $imageRoot := merge .Values.image $tag -}} |
| 19 | +{{- end -}} |
| 20 | +{{- include "common.images.image" (dict "imageRoot" $imageRoot "global" .Values.global) -}} |
| 21 | +{{- end -}} |
| 22 | + |
| 23 | +{{/* |
| 24 | +Return the Function Secret Name |
| 25 | +*/}} |
| 26 | +{{- define "function.secretName" -}} |
| 27 | +{{- if .Values.function.existingSecret }} |
| 28 | + {{- printf "%s" .Values.function.existingSecret -}} |
| 29 | +{{- else -}} |
| 30 | + {{- printf "%s" (include "common.names.fullname" .) -}} |
| 31 | +{{- end -}} |
| 32 | +{{- end -}} |
| 33 | + |
| 34 | +{{/* |
| 35 | +Return the Redis™ hostname |
| 36 | +*/}} |
| 37 | +{{- define "function.redisHost" -}} |
| 38 | +{{- if .Values.redis.enabled }} |
| 39 | + {{- printf "%s-master" (include "function.redis.fullname" .) -}} |
| 40 | +{{- else -}} |
| 41 | + {{- printf "%s" .Values.externalDatabase.host -}} |
| 42 | +{{- end -}} |
| 43 | +{{- end -}} |
| 44 | + |
| 45 | +{{/* |
| 46 | +Return the Redis™ port |
| 47 | +*/}} |
| 48 | +{{- define "function.redisPort" -}} |
| 49 | +{{- if .Values.redis.enabled }} |
| 50 | + {{- printf "6379" | quote -}} |
| 51 | +{{- else -}} |
| 52 | + {{- .Values.externalDatabase.port | quote -}} |
| 53 | +{{- end -}} |
| 54 | +{{- end -}} |
| 55 | + |
| 56 | +{{/* |
| 57 | +Return true if a secret object for Redis™ should be created |
| 58 | +*/}} |
| 59 | +{{- define "function.redis.createSecret" -}} |
| 60 | +{{- if and (not .Values.redis.enabled) (not .Values.externalDatabase.existingSecret) .Values.externalDatabase.password }} |
| 61 | + {{- true -}} |
| 62 | +{{- end -}} |
| 63 | +{{- end -}} |
| 64 | + |
| 65 | +{{/* |
| 66 | +Return the Redis™ secret name |
| 67 | +*/}} |
| 68 | +{{- define "function.redis.secretName" -}} |
| 69 | +{{- if .Values.redis.enabled }} |
| 70 | + {{- if .Values.redis.auth.existingSecret }} |
| 71 | + {{- printf "%s" .Values.redis.auth.existingSecret -}} |
| 72 | + {{- else -}} |
| 73 | + {{- printf "%s" (include "function.redis.fullname" .) -}} |
| 74 | + {{- end -}} |
| 75 | +{{- else if .Values.externalDatabase.existingSecret }} |
| 76 | + {{- printf "%s" .Values.externalDatabase.existingSecret -}} |
| 77 | +{{- else -}} |
| 78 | + {{- printf "%s-redis" (include "common.names.fullname" .) -}} |
| 79 | +{{- end -}} |
| 80 | +{{- end -}} |
| 81 | + |
| 82 | +{{/* |
| 83 | +Return the Redis™ secret key |
| 84 | +*/}} |
| 85 | +{{- define "function.redis.secretPasswordKey" -}} |
| 86 | +{{- if and .Values.redis.enabled .Values.redis.auth.existingSecret }} |
| 87 | + {{- required "You need to provide existingSecretPasswordKey when an existingSecret is specified in redis" .Values.redis.auth.existingSecretPasswordKey | printf "%s" }} |
| 88 | +{{- else if and (not .Values.redis.enabled) .Values.externalDatabase.existingSecret }} |
| 89 | + {{- required "You need to provide existingSecretPasswordKey when an existingSecret is specified in redis" .Values.externalDatabase.existingSecretPasswordKey | printf "%s" }} |
| 90 | +{{- else -}} |
| 91 | + {{- printf "redis-password" -}} |
| 92 | +{{- end -}} |
| 93 | +{{- end -}} |
| 94 | + |
| 95 | +{{/* |
| 96 | +Return whether Redis™ uses password authentication or not |
| 97 | +*/}} |
| 98 | +{{- define "function.redis.auth.enabled" -}} |
| 99 | +{{- if or (and .Values.redis.enabled .Values.redis.auth.enabled) (and (not .Values.redis.enabled) (or .Values.externalDatabase.password .Values.externalDatabase.existingSecret)) }} |
| 100 | + {{- true -}} |
| 101 | +{{- end -}} |
| 102 | +{{- end -}} |
0 commit comments