feat(lab4): implement S3 attachments with fault tolerance

This commit is contained in:
sashadugina06
2026-11-06 18:15:53 +03:00
parent ec540a1a72
commit b4704b47b2
67 changed files with 3436 additions and 46 deletions
+21
View File
@@ -0,0 +1,21 @@
"""Generate local credentials once; never overwrite an existing secret."""
from pathlib import Path
import secrets
root = Path(__file__).resolve().parents[1]
directory = root / 'secrets'
directory.mkdir(mode=0o700, exist_ok=True)
values = {'postgres_password': secrets.token_hex(24), 's3_root_user': 'lab4root', 's3_root_password': secrets.token_hex(24), 's3_access_key_id': 'lab4api', 's3_secret_access_key': secrets.token_hex(24)}
for name, value in values.items():
path = directory / name
if not path.exists():
path.write_text(value + '\n')
path.chmod(0o600)
path = directory / 'database_url'
if not path.exists():
password = (directory / 'postgres_password').read_text().strip()
path.write_text(f'postgresql://messenger:{password}@postgres:5432/messenger\n')
path.chmod(0o600)
path = root / '.env'
if not path.exists():
path.write_text('COMPOSE_PROJECT_NAME=mtusi2026lab4\nPUBLIC_PORT=8084\n')
print('Local configuration ready (secret values suppressed)')