@@ -165,6 +165,48 @@ Create the database port based on backend selection
165165{ {- end } }
166166{ {- end } }
167167
168+ { {/*
169+ Determine the Redis service name when the bundled chart is enabled
170+ */} }
171+ { {- define " stac-fastapi.redisServiceName" -} }
172+ { {- if .Values.redis.fullnameOverride } }
173+ { {- printf " %s-master" .Values.redis.fullnameOverride } }
174+ { {- else } }
175+ { {- printf " %s-redis-master" .Release.Name } }
176+ { {- end } }
177+ { {- end } }
178+
179+ { {/*
180+ Compute the Redis host, preferring the bundled deployment when enabled
181+ */} }
182+ { {- define " stac-fastapi.redisHost" -} }
183+ { {- if and (.Values.redis.enabled) (not (and .Values.redis.external .Values.redis.external.enabled)) -} }
184+ { {- $service := include " stac-fastapi.redisServiceName" . | trim -} }
185+ { {- $namespace := .Release.Namespace | default " default" -} }
186+ { {- $clusterDomain := default " cluster.local" .Values.global.clusterDomain -} }
187+ { {- printf " %s.%s.svc.%s" $service $namespace $clusterDomain -} }
188+ { {- else if and .Values.redis.external .Values.redis.external.enabled -} }
189+ { {- .Values.redis.external.host | default " " -} }
190+ { {- else -} }
191+ { {- " " -} }
192+ { {- end } }
193+ { {- end } }
194+
195+ { {/*
196+ Resolve the Redis port based on the active configuration
197+ */} }
198+ { {- define " stac-fastapi.redisPort" -} }
199+ { {- if and (.Values.redis.enabled) (not (and .Values.redis.external .Values.redis.external.enabled)) -} }
200+ { {- $ports := default (dict) (dig " master" " service" " ports" (dict) .Values.redis) -} }
201+ { {- $port := default 6379 (index $ports " redis" ) -} }
202+ { {- $port -} }
203+ { {- else if and .Values.redis.external .Values.redis.external.enabled -} }
204+ { {- .Values.redis.external.port | default 6379 -} }
205+ { {- else -} }
206+ { {- 6379 -} }
207+ { {- end } }
208+ { {- end } }
209+
168210{ {/*
169211Create the image repository with tag
170212*/} }
@@ -186,6 +228,9 @@ Create environment variables for the application
186228{ {- $envFromSecret := default (dict) .Values.app.envFromSecret -} }
187229{ {- $dbAuth := deepCopy (default (dict) .Values.app.databaseAuth) -} }
188230{ {- $opensearchSecurity := default (dict) .Values.opensearchSecurity -} }
231+ { {- $redisConfig := default (dict) .Values.redis -} }
232+ { {- $redisExternal := default (dict) (get $redisConfig " external" ) -} }
233+ { {- $redisEnabled := or ($redisConfig .enabled) (and $redisExternal ($redisExternal .enabled)) -} }
189234{ {- if and (eq .Values.backend " opensearch" ) (get $opensearchSecurity " generateAdminPassword" ) } }
190235 { {- $secretName := include " stac-fastapi.opensearchAdminSecretName" . -} }
191236 { {- if or (not (hasKey $dbAuth " existingSecret" )) (not $dbAuth .existingSecret) } }
0 commit comments