43cb339605
Run scans in background with progress/status updates and store scan metrics in memory or PostgreSQL. Made-with: Cursor
40 lines
653 B
Go
40 lines
653 B
Go
package config
|
|
|
|
import "os"
|
|
|
|
type Config struct {
|
|
HTTPAddr string
|
|
DBDSN string
|
|
StoreBackend string
|
|
RunMigrations bool
|
|
}
|
|
|
|
func FromEnv() Config {
|
|
addr := os.Getenv("HTTP_ADDR")
|
|
if addr == "" {
|
|
addr = ":8080"
|
|
}
|
|
|
|
dbDSN := os.Getenv("DB_DSN")
|
|
storeBackend := os.Getenv("STORE_BACKEND")
|
|
if storeBackend == "" {
|
|
if dbDSN != "" {
|
|
storeBackend = "postgres"
|
|
} else {
|
|
storeBackend = "memory"
|
|
}
|
|
}
|
|
|
|
runMigrations := true
|
|
if os.Getenv("RUN_MIGRATIONS") == "false" {
|
|
runMigrations = false
|
|
}
|
|
|
|
return Config{
|
|
HTTPAddr: addr,
|
|
DBDSN: dbDSN,
|
|
StoreBackend: storeBackend,
|
|
RunMigrations: runMigrations,
|
|
}
|
|
}
|