Skip to content

Commit 6ba9004

Browse files
committed
fix: honor DATABASE_USER/DATABASE_PASS with DATABASE_SOCKET_DIR
1 parent 6982621 commit 6ba9004

2 files changed

Lines changed: 13 additions & 6 deletions

File tree

config/runtime.exs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,16 @@ case System.get_env("DATABASE_SOCKET_DIR") do
110110
port: System.get_env("DATABASE_PORT", "5432")
111111

112112
socket_dir ->
113-
config :teslamate, TeslaMate.Repo,
114-
socket_dir: socket_dir,
115-
port: System.get_env("DATABASE_PORT", "5432")
113+
repo_config =
114+
[
115+
socket_dir: socket_dir,
116+
port: System.get_env("DATABASE_PORT", "5432"),
117+
username: System.get_env("DATABASE_USER"),
118+
password: System.get_env("DATABASE_PASS")
119+
]
120+
|> Enum.reject(fn {_key, value} -> is_nil(value) end)
121+
122+
config :teslamate, TeslaMate.Repo, repo_config
116123
end
117124

118125
config :teslamate, TeslaMate.Repo,

website/docs/configuration/environment_variables.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ TeslaMate accepts the following environment variables for runtime configuration:
99
| Variable Name | Description | Default Value |
1010
| -------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
1111
| **ENCRYPTION_KEY** | A key used to encrypt the Tesla API tokens (**required**) | |
12-
| **DATABASE_USER** | Username | |
13-
| **DATABASE_PASS** | User password | |
12+
| **DATABASE_USER** | Username. Also used with `DATABASE_SOCKET_DIR` when the socket connection requires password authentication. | |
13+
| **DATABASE_PASS** | User password. Also used with `DATABASE_SOCKET_DIR` when the socket connection requires password authentication. | |
1414
| **DATABASE_NAME** | The database to connect to | |
1515
| **DATABASE_HOST** | Hostname of the database server | |
1616
| **DATABASE_PORT** | Port of the database server | 5432 |
17-
| **DATABASE_SOCKET_DIR** | Local path containing UNIX socket for database if that connection mechanic is preferred. Provide one of `DATABASE_SOCKET_DIR` and `DATABASE_(USER\|PASS\|HOST)` | |
17+
| **DATABASE_SOCKET_DIR** | Local path containing a UNIX socket for the database. `DATABASE_USER` and `DATABASE_PASS` are honored when set; omit them to use peer authentication. | |
1818
| **DATABASE_POOL_SIZE** | Size of the database connection pool | 10 |
1919
| **DATABASE_TIMEOUT** | The time in milliseconds to wait for database query calls to finish | 60000 |
2020
| **DATABASE_SSL** | Set to `true` if SSL should be enabled or `noverify` if certificate verification should not be performed. | false |

0 commit comments

Comments
 (0)