eust-w 43326d6a5e feat(platform): land workflow, data tooling, and docs updates
Include the accumulated workflow scheduling, run history, subtree rerun, operator UI, deployment, data asset, object storage, database browser, and documentation changes currently in the worktree.
2026-04-24 12:29:46 +08:00

66 lines
2.2 KiB
Go

package config
import (
"os"
"path/filepath"
"strconv"
"strings"
)
type AppConfig struct {
Port int
WorkerPort int
MongoURI string
MongoDB string
MongoConnectRetries int
MongoConnectRetryDelayMS int
PollIntervalMS int
K8sNamespace string
K8sImagePullSecretName string
WorkspacePVCName string
WorkspaceMountPath string
OperatorRunnerImage string
AIAPIBaseURL string
AIAPIKey string
AIModel string
DistDir string
}
func parseInt(value string, fallback int) int {
parsed, err := strconv.Atoi(value)
if err != nil {
return fallback
}
return parsed
}
func Load() AppConfig {
workingDirectory, _ := os.Getwd()
return AppConfig{
Port: parseInt(os.Getenv("PORT"), 3001),
WorkerPort: parseInt(os.Getenv("WORKER_PORT"), 3002),
MongoURI: getenv("MONGO_URI", "mongodb://127.0.0.1:27017"),
MongoDB: getenv("MONGO_DB", "droboticflow"),
MongoConnectRetries: parseInt(os.Getenv("MONGO_CONNECT_RETRIES"), 30),
MongoConnectRetryDelayMS: parseInt(os.Getenv("MONGO_CONNECT_RETRY_DELAY_MS"), 2000),
PollIntervalMS: parseInt(os.Getenv("WORKER_POLL_INTERVAL_MS"), 2000),
K8sNamespace: getenv("K8S_NAMESPACE", "droboticflow"),
K8sImagePullSecretName: getenv("K8S_IMAGE_PULL_SECRET_NAME", "droboticflow-registry"),
WorkspacePVCName: strings.TrimSpace(os.Getenv("WORKSPACE_PVC_NAME")),
WorkspaceMountPath: getenv("WORKSPACE_MOUNT_PATH", "/workspace"),
OperatorRunnerImage: getenv("OPERATOR_RUNNER_IMAGE", "ccr-29eug8s3-pub.cnc.bj.baidubce.com/dataflow/droboticflow-operator-runner:latest"),
AIAPIBaseURL: getenv("AI_API_BASE_URL", "https://coding.dashscope.aliyuncs.com/v1"),
AIAPIKey: os.Getenv("AI_API_KEY"),
AIModel: getenv("AI_MODEL", "glm-5"),
DistDir: getenv("DIST_DIR", filepath.Join(workingDirectory, "dist")),
}
}
func getenv(key string, fallback string) string {
value := os.Getenv(key)
if value == "" {
return fallback
}
return value
}