webdav fix

This commit is contained in:
2025-10-31 20:10:42 +01:00
parent 175387f0d3
commit e9731ec691
9 changed files with 110 additions and 8 deletions
+4 -2
View File
@@ -3,8 +3,10 @@
{{- $config := dict "databaseUrl" .Values.backend.env.databaseUrl -}}
{{- if not (index $config "databaseUrl") -}}
{{- if .Values.postgres.enabled -}}
{{- $dbUser := required "postgres.auth.username is required when postgres.enabled" .Values.postgres.auth.username -}}
{{- $dbPass := required "postgres.auth.password is required when postgres.enabled" .Values.postgres.auth.password -}}
{{- $appUser := default .Values.postgres.auth.username .Values.postgres.auth.appUsername -}}
{{- $appPass := default .Values.postgres.auth.password .Values.postgres.auth.appPassword -}}
{{- $dbUser := required "postgres auth appUsername/password (or username/password) must be provided when postgres.enabled" $appUser -}}
{{- $dbPass := required "postgres auth appUsername/password (or username/password) must be provided when postgres.enabled" $appPass -}}
{{- $dbName := default "papercrate" .Values.backend.env.databaseName -}}
{{- $dbHost := printf "%s-postgres" (include "papercrate.fullname" .) -}}
{{- $_ := set $config "databaseUrl" (printf "postgres://%s:%s@%s:5432/%s" $dbUser $dbPass $dbHost $dbName) -}}
@@ -17,6 +17,44 @@ data:
-c "CREATE DATABASE \"{{ $name }}\"";
fi
{{- end }}
{{- $appRole := default "" .Values.postgres.auth.appRole }}
{{- $appUser := default "" .Values.postgres.auth.appUsername }}
{{- $appPassword := default "" .Values.postgres.auth.appPassword }}
APP_ROLE="{{ $appRole }}"
APP_USER="{{ $appUser }}"
APP_PASSWORD="{{ $appPassword }}"
APP_DATABASE="{{ default "papercrate" .Values.backend.env.databaseName }}"
if [ -n "$APP_ROLE" ]; then
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname postgres <<-EOSQL
DO $$
BEGIN
IF NOT EXISTS (SELECT 1 FROM pg_roles WHERE rolname = '$APP_ROLE') THEN
CREATE ROLE "$APP_ROLE" NOLOGIN;
END IF;
END
$$;
EOSQL
fi
if [ -n "$APP_USER" ] && [ -n "$APP_PASSWORD" ]; then
psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" --dbname postgres <<-EOSQL
DO $$
BEGIN
IF NOT EXISTS (SELECT 1 FROM pg_roles WHERE rolname = '$APP_USER') THEN
CREATE ROLE "$APP_USER" LOGIN PASSWORD '$APP_PASSWORD';
ELSE
ALTER ROLE "$APP_USER" WITH LOGIN PASSWORD '$APP_PASSWORD';
END IF;
IF '$APP_ROLE' <> '' THEN
GRANT "$APP_ROLE" TO "$APP_USER";
END IF;
END
$$;
GRANT CONNECT ON DATABASE "$APP_DATABASE" TO "$APP_USER";
GRANT USAGE ON SCHEMA public TO "$APP_USER";
ALTER ROLE "$APP_USER" SET search_path = 'tenant, shared, public';
ALTER ROLE "$APP_USER" INHERIT;
EOSQL
fi
if [ -n "$PGDATA" ] && [ -f "$PGDATA/postgresql.conf" ]; then
if grep -q "^max_connections" "$PGDATA/postgresql.conf"; then
sed -i "s/^max_connections.*/max_connections = {{ .Values.postgres.maxConnections | default 200 }}/" "$PGDATA/postgresql.conf"
@@ -35,10 +35,7 @@ spec:
{{- fail "quickwit.env.storageUri must be set, or provide global.s3.bucket" -}}
{{- end -}}
{{- if and (not (index $qw "metastoreUri")) .Values.postgres.enabled -}}
{{- $dbUser := required "postgres.auth.username is required when postgres.enabled" .Values.postgres.auth.username -}}
{{- $dbPass := required "postgres.auth.password is required when postgres.enabled" .Values.postgres.auth.password -}}
{{- $dbHost := printf "%s-postgres" (include "papercrate.fullname" .) -}}
{{- $_ := set $qw "metastoreUri" (printf "postgres://%s:%s@%s:5432/quickwit" $dbUser $dbPass $dbHost) -}}
{{- $_ := fail "quickwit.env.metastoreSecret must be provided when using chart-managed Postgres" -}}
{{- end -}}
{{- if not (index $qw "metastoreUri") -}}
{{- fail "quickwit.env.metastoreUri must be set when not using bundled Postgres" -}}
@@ -55,8 +52,16 @@ spec:
env:
- name: QW_STORAGE_URI
value: {{ index $qw "storageUri" | quote }}
{{- if .Values.quickwit.env.metastoreSecret }}
- name: QW_METASTORE_URI
valueFrom:
secretKeyRef:
name: {{ .Values.quickwit.env.metastoreSecret }}
key: metastoreUri
{{- else }}
- name: QW_METASTORE_URI
value: {{ index $qw "metastoreUri" | quote }}
{{- end }}
{{- with .Values.global.s3.endpoint }}
- name: AWS_ENDPOINT_URL
value: {{ . | quote }}