veza/veza-backend-api/internal/config
senke d03232c85c
Some checks failed
Veza CI / Backend (Go) (push) Failing after 0s
Veza CI / Frontend (Web) (push) Failing after 0s
Veza CI / Rust (Stream Server) (push) Failing after 0s
Security Scan / Secret Scanning (gitleaks) (push) Failing after 0s
Veza CI / Notify on failure (push) Failing after 0s
feat(storage): add track storage_backend column + config prep (v1.0.8 P0)
Phase 0 of the MinIO upload migration (FUNCTIONAL_AUDIT §4 item 2).
Schema + config only — Phase 1 will wire TrackService.UploadTrack()
to actually route writes to S3 when the flag is flipped.

Schema (migration 985):
- tracks.storage_backend VARCHAR(16) NOT NULL DEFAULT 'local'
  CHECK in ('local', 's3')
- tracks.storage_key VARCHAR(512) NULL (S3 object key when backend=s3)
- Partial index on storage_backend = 's3' (migration progress queries)
- Rollback drops both columns + index; safe only while all rows are
  still 'local' (guard query in the rollback comment)

Go model (internal/models/track.go):
- StorageBackend string (default 'local', not null)
- StorageKey *string (nullable)
- Both tagged json:"-" — internal plumbing, never exposed publicly

Config (internal/config/config.go):
- New field Config.TrackStorageBackend
- Read from TRACK_STORAGE_BACKEND env var (default 'local')
- Production validation rule #11 (ValidateForEnvironment):
  - Must be 'local' or 's3' (reject typos like 'S3' or 'minio')
  - If 's3', requires AWS_S3_ENABLED=true (fail fast, do not boot with
    TrackStorageBackend=s3 while S3StorageService is nil)
- Dev/staging warns and falls back to 'local' instead of fail — keeps
  iteration fast while still flagging misconfig.

Docs:
- docs/ENV_VARIABLES.md §13 restructured as "HLS + track storage backend"
  with a migration playbook (local → s3 → migrate-storage CLI)
- docs/ENV_VARIABLES.md §28 validation rules: +2 entries for new rules
- docs/ENV_VARIABLES.md §29 drift findings: TRACK_STORAGE_BACKEND added
  to "missing from template" list before it was fixed
- veza-backend-api/.env.template: TRACK_STORAGE_BACKEND=local with
  comment pointing at Phase 1/2/3 plans

No behavior change yet — TrackService.UploadTrack() still hardcodes the
local path via copyFileAsync(). Phase 1 wires it.

Refs:
- AUDIT_REPORT.md §9 item (deferrals v1.0.8)
- FUNCTIONAL_AUDIT.md §4 item 2 "Stockage local disque only"
- /home/senke/.claude/plans/audit-fonctionnel-wild-hickey.md Item 3

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-23 19:54:28 +02:00
..
config.go feat(storage): add track storage_backend column + config prep (v1.0.8 P0) 2026-04-23 19:54:28 +02:00
config_test.go fix(config): refuse boot in production when HYPERSWITCH_ENABLED=false 2026-04-16 14:55:18 +02:00
cors.go feat: backend, stream server & infra improvements 2026-03-18 11:36:06 +01:00
db_init.go refactor(config): découper config.go par domaine (audit 2.7) 2026-02-15 14:44:33 +01:00
defaults.go adding initial backend API (Go) 2025-12-03 20:29:37 +01:00
defaults_test.go adding initial backend API (Go) 2025-12-03 20:29:37 +01:00
docs.go adding initial backend API (Go) 2025-12-03 20:29:37 +01:00
docs_test.go adding initial backend API (Go) 2025-12-03 20:29:37 +01:00
env_detection.go adding initial backend API (Go) 2025-12-03 20:29:37 +01:00
env_detection_test.go adding initial backend API (Go) 2025-12-03 20:29:37 +01:00
env_helpers.go feat(backend): OAuth FRONTEND_URL from config, docs update 2026-02-17 16:42:23 +01:00
env_loader.go adding initial backend API (Go) 2025-12-03 20:29:37 +01:00
env_loader_test.go adding initial backend API (Go) 2025-12-03 20:29:37 +01:00
middlewares_init.go feat(middleware): wire UserRateLimiter into AuthMiddleware (BE-SVC-002) 2026-04-21 09:52:07 +02:00
rabbitmq.go feat: backend — config, handlers, services, logging, migration 2026-03-23 15:46:57 +01:00
rate_limit.go feat: backend, stream server & infra improvements 2026-03-18 11:36:06 +01:00
redis_init.go refactor(config): découper config.go par domaine (audit 2.7) 2026-02-15 14:44:33 +01:00
reloader.go adding initial backend API (Go) 2025-12-03 20:29:37 +01:00
reloader_test.go v0.9.4 2026-03-05 23:03:43 +01:00
secrets.go [BE-SEC-014] be-sec: Implement secrets management 2025-12-24 12:30:18 +01:00
secrets_test.go STABILISATION: phase 3–5 – API contract, tests & chat-server hardening 2025-12-06 17:21:59 +01:00
services_init.go v0.9.1 2026-03-05 19:22:31 +01:00
testutils.go fix(backend): use explicit DISABLE_RATE_LIMIT_FOR_TESTS flag instead of env-based bypass 2026-02-15 15:56:53 +01:00
testutils_test.go adding initial backend API (Go) 2025-12-03 20:29:37 +01:00
upload_limits.go feat(backend,web): single source of truth for upload-size limits 2026-04-16 19:37:37 +02:00
upload_limits_test.go feat(backend,web): single source of truth for upload-size limits 2026-04-16 19:37:37 +02:00
validation.go refactor(backend): split config into domain modules (P2) 2026-02-16 11:12:21 +01:00
validation_test.go fix(chat,config): require REDIS_URL in prod + error on in-memory fallback 2026-04-16 14:56:47 +02:00
validator.go adding initial backend API (Go) 2025-12-03 20:29:37 +01:00
validator_test.go adding initial backend API (Go) 2025-12-03 20:29:37 +01:00
watcher.go adding initial backend API (Go) 2025-12-03 20:29:37 +01:00
watcher_test.go adding initial backend API (Go) 2025-12-03 20:29:37 +01:00