apiVersion: v1
kind: ConfigMap
metadata:
  name: manila-db-maintain
  labels:
    system: openstack
    type: configuration
    component: database

data:
  db-maintain.sh: |
    #!/usr/bin/env bash
    export PGUSER={{ default "postgres" .Values.postgresql.postgresUser }}
    psql <<- EOSQL
      ALTER ROLE {{ .Values.global.dbUser }} WITH ENCRYPTED PASSWORD '{{.Values.global.dbPassword | default (tuple . .Values.global.dbUser | include "postgres.password_for_user")}}' SUPERUSER;
      ALTER ROLE {{ .Values.postgresql.postgresUser }} WITH ENCRYPTED PASSWORD '{{.Values.postgresql.postgresPassword | default (tuple . .Values.postgresql.postgresUser | include "postgres.password_for_user")}}' SUPERUSER;
    EOSQL
