Changeset 0.12.0 (#63)

This commit is contained in:
2026-02-25 21:38:49 +00:00
parent c9d8e9457e
commit 88216ec4cb
59 changed files with 13115 additions and 139 deletions

View File

@@ -2,6 +2,7 @@ package config
import (
"os"
"strconv"
"github.com/joho/godotenv"
)
@@ -26,6 +27,28 @@ type Config struct {
// Used to derive AES-256 key for global/team provider API keys.
// Personal keys use per-user UEK (derived from password).
EncryptionKey string
// File storage (v0.12.0+)
// STORAGE_BACKEND: "pvc" or "s3". Empty = auto-detect (pvc if path writable).
// STORAGE_PATH: mount point for PVC backend (default /data/storage).
StorageBackend string
StoragePath string
// S3-compatible storage (v0.12.0+)
// Works with AWS S3, MinIO, Ceph RGW, or any S3-compatible API.
S3Endpoint string // custom endpoint URL (required for MinIO/Ceph, optional for AWS)
S3Bucket string // bucket name (required when STORAGE_BACKEND=s3)
S3Region string // AWS region (default "us-east-1")
S3AccessKey string // access key ID
S3SecretKey string // secret access key
S3Prefix string // optional key prefix within bucket (e.g. "switchboard/")
S3ForcePathStyle bool // use path-style URLs (required for MinIO, most self-hosted)
// Extraction pipeline (v0.12.0+)
// EXTRACTION_MODE: "inline" (in-process) or "sidecar" (shared PVC watcher).
// EXTRACTION_CONCURRENCY: max concurrent extraction jobs (default 3).
ExtractionMode string
ExtractionConcurrency int
}
// Load reads configuration from environment variables.
@@ -45,6 +68,18 @@ func Load() *Config {
AdminEmail: getEnv("SWITCHBOARD_ADMIN_EMAIL", ""),
SeedUsers: getEnv("SEED_USERS", ""),
EncryptionKey: getEnv("ENCRYPTION_KEY", ""),
StorageBackend: getEnv("STORAGE_BACKEND", ""),
StoragePath: getEnv("STORAGE_PATH", "/data/storage"),
S3Endpoint: getEnv("S3_ENDPOINT", ""),
S3Bucket: getEnv("S3_BUCKET", ""),
S3Region: getEnv("S3_REGION", "us-east-1"),
S3AccessKey: getEnv("S3_ACCESS_KEY", ""),
S3SecretKey: getEnv("S3_SECRET_KEY", ""),
S3Prefix: getEnv("S3_PREFIX", ""),
S3ForcePathStyle: getEnv("S3_FORCE_PATH_STYLE", "true") == "true",
ExtractionMode: getEnv("EXTRACTION_MODE", "inline"),
ExtractionConcurrency: getEnvInt("EXTRACTION_CONCURRENCY", 3),
}
}
@@ -71,3 +106,12 @@ func getEnv(key, fallback string) string {
}
return fallback
}
func getEnvInt(key string, fallback int) int {
if v := os.Getenv(key); v != "" {
if n, err := strconv.Atoi(v); err == nil {
return n
}
}
return fallback
}