feat: add worker config reader with secret decryption
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
import psycopg
|
||||
|
||||
from lyra_worker.crypto import decrypt_secret
|
||||
|
||||
|
||||
def get_config(conn: psycopg.Connection) -> dict[str, str]:
|
||||
"""Return all config as {key: value}, decrypting rows marked secret."""
|
||||
with conn.cursor() as cur:
|
||||
cur.execute('SELECT key, value, secret FROM "Config"')
|
||||
rows = cur.fetchall()
|
||||
out: dict[str, str] = {}
|
||||
for key, value, secret in rows:
|
||||
out[key] = decrypt_secret(value) if secret else value
|
||||
return out
|
||||
Reference in New Issue
Block a user