feat: field-sync-gui MVP — Wails GUI ingest SD→local+S3 (4 slots //)
This commit is contained in:
42
internal/config/config.go
Normal file
42
internal/config/config.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"os"
|
||||
"strconv"
|
||||
|
||||
"github.com/joho/godotenv"
|
||||
)
|
||||
|
||||
// Config holds runtime configuration
|
||||
type Config struct {
|
||||
S3Bucket string `json:"s3Bucket"`
|
||||
LocalDest string `json:"localDest"`
|
||||
AWSProfile string `json:"awsProfile"`
|
||||
Concurrency int `json:"concurrency"`
|
||||
}
|
||||
|
||||
// Load reads config from ENV (with optional .env file)
|
||||
func Load(envFile string) Config {
|
||||
_ = godotenv.Load(envFile) // ignore if missing
|
||||
|
||||
concurrency := 4
|
||||
if v := os.Getenv("FIELD_SYNC_CONCURRENCY"); v != "" {
|
||||
if n, err := strconv.Atoi(v); err == nil && n > 0 {
|
||||
concurrency = n
|
||||
}
|
||||
}
|
||||
|
||||
return Config{
|
||||
S3Bucket: getenv("FIELD_SYNC_S3_BUCKET", ""),
|
||||
LocalDest: getenv("FIELD_SYNC_LOCAL_DEST", os.TempDir()),
|
||||
AWSProfile: getenv("AWS_PROFILE", "cosma"),
|
||||
Concurrency: concurrency,
|
||||
}
|
||||
}
|
||||
|
||||
func getenv(key, fallback string) string {
|
||||
if v := os.Getenv(key); v != "" {
|
||||
return v
|
||||
}
|
||||
return fallback
|
||||
}
|
||||
Reference in New Issue
Block a user