Use urlquery to encode postgres password

This commit is contained in:
Daniel Berteaud 2024-01-19 15:18:36 +01:00
parent 4996bc9e57
commit c3b6ceaf99
2 changed files with 2 additions and 2 deletions

View File

@ -121,7 +121,7 @@ job "miniflux" {
template {
data = <<_EOT
DATABASE_URL=postgresql://{{ with secret "database/creds/miniflux" }}{{ .Data.username }}{{ end }}:{{ with secret "database/creds/miniflux" }}{{ .Data.password }}{{ end }}@127.0.0.1:5432/miniflux?sslmode=disable
DATABASE_URL=postgresql://{{ with secret "database/creds/miniflux" }}{{ .Data.username }}{{ end }}:{{ with secret "database/creds/miniflux" }}{{ urlquery .Data.password }}{{ end }}@127.0.0.1:5432/miniflux?sslmode=disable
_EOT
destination = "secrets/.db.env"
perms = 400

View File

@ -88,7 +88,7 @@ DATABASE_URL=postgresql://
[[- if ne $c.postgres.pooler.engine "none" -]]
[[ .instance ]]:{{ env "NOMAD_ALLOC_ID" }}@127.0.0.1:[[ $c.postgres.pooler.port ]]/[[ $c.postgres.database ]]?sslmode=disable
[[- else -]]
[[ $c.postgres.user ]]:[[ $c.postgres.password ]]@[[ $c.postgres.host ]]:[[ $c.postgres.port ]]/[[ $c.postgres.database ]]?sslmode=disable
[[ $c.postgres.user ]]:[[ $c.postgres.password | regexp.Replace "\\.Data\\.password" "urlquery .Data.password" ]]@[[ $c.postgres.host ]]:[[ $c.postgres.port ]]/[[ $c.postgres.database ]]?sslmode=disable
[[- end ]]
_EOT
destination = "secrets/.db.env"