@@ -156,3 +156,86 @@ spec:
156156 {{- end }}
157157 backoffLimit : 3
158158{{- end }}
159+
160+ {{- if and .Values.pgstacBootstrap.enabled .Values.pgstacBootstrap.settings.queryables }}
161+ ---
162+ apiVersion : batch/v1
163+ kind : Job
164+ metadata :
165+ name : {{ .Release.Name }}-pgstac-load-queryables
166+ labels :
167+ app : {{ .Release.Name }}-pgstac-load-queryables
168+ annotations :
169+ helm.sh/hook : " post-install,post-upgrade"
170+ helm.sh/hook-weight : " -3"
171+ helm.sh/hook-delete-policy : " before-hook-creation"
172+ spec :
173+ template :
174+ metadata :
175+ labels :
176+ app : {{ .Release.Name }}-pgstac-load-queryables
177+ spec :
178+ restartPolicy : Never
179+ containers :
180+ - name : pgstac-load-queryables
181+ image : {{ .Values.pgstacBootstrap.image.name }}:{{ .Values.pgstacBootstrap.image.tag }}
182+ command :
183+ - " /bin/sh"
184+ - " -c"
185+ args :
186+ - |
187+ # Exit immediately if a command exits with a non-zero status
188+ set -e
189+
190+ # Database connection configured through standard PG* environment variables
191+ # Environment variables are already set by the container
192+
193+ # Wait for the database to be ready
194+ echo "Waiting for database to be ready..."
195+ pypgstac pgready
196+
197+ # Load queryables configurations
198+ echo "Loading queryables configurations..."
199+ {{- range $idx, $config := .Values.pgstacBootstrap.settings.queryables }}
200+ {{- $filename := splitList "/" $config.file | last }}
201+ echo "Processing queryables file: {{ $filename }}"
202+ pypgstac load-queryables \
203+ {{- if $config.deleteMissing }}
204+ --delete-missing \
205+ {{- end }}
206+ {{- if $config.collections }}
207+ # Complex escaping needed due to multiple interpretation layers:
208+ # 1. Helm processes the template: \\\" becomes \" in the rendered YAML
209+ # 2. YAML processes the string: \" becomes " in the shell script
210+ # 3. Shell receives: --collection-ids '["collection1","collection2"]'
211+ # 4. pypgstac gets a proper JSON array string as expected
212+ --collection-ids "[\\\"{{ join "\\\",\\\"" $config.collections }}\\\"]" \
213+ {{- end }}
214+ {{- if $config.indexFields }}
215+ --index-fields {{ join "," $config.indexFields }} \
216+ {{- end }}
217+ "/opt/queryables/{{ $filename }}"
218+ {{- end }}
219+
220+ echo "Queryables loading complete"
221+ resources :
222+ {{- toYaml .Values.pgstacBootstrap.settings.resources | nindent 12 }}
223+ volumeMounts :
224+ - mountPath : /opt/queryables
225+ name : {{ .Release.Name }}-queryables-volume
226+ env :
227+ {{- include "eoapi.postgresqlEnv" . | nindent 12 }}
228+ volumes :
229+ - name : {{ .Release.Name }}-queryables-volume
230+ configMap :
231+ name : {{ .Release.Name }}-pgstac-queryables-config
232+ {{- with .Values.pgstacBootstrap.settings.affinity }}
233+ affinity :
234+ {{- toYaml . | nindent 8 }}
235+ {{- end }}
236+ {{- with .Values.pgstacBootstrap.settings.tolerations }}
237+ tolerations :
238+ {{- toYaml . | nindent 8 }}
239+ {{- end }}
240+ backoffLimit : 3
241+ {{- end }}
0 commit comments