You've already forked agentic-coding-workflow
feat(app): wire workspace module + integration test for ws closed loop
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
@@ -34,6 +35,8 @@ type Config struct {
|
||||
HTTP HTTPConfig `mapstructure:"http"`
|
||||
DB DBConfig `mapstructure:"db"`
|
||||
Bootstrap BootstrapConfig `mapstructure:"bootstrap"`
|
||||
Workspace Workspace `mapstructure:"workspace"`
|
||||
Git Git `mapstructure:"git"`
|
||||
}
|
||||
|
||||
// HTTPConfig 描述 HTTP 服务监听参数。
|
||||
@@ -52,6 +55,21 @@ type BootstrapConfig struct {
|
||||
AdminPassword string `mapstructure:"admin_password"`
|
||||
}
|
||||
|
||||
// Workspace 控制 workspace 模块的磁盘与超时(数据目录、每个 git verb 的超时)。
|
||||
// DataDir 是 workspace clone/worktree 落盘根目录;五个 timeout 直接灌进 git.Config。
|
||||
type Workspace struct {
|
||||
DataDir string `mapstructure:"data_dir"`
|
||||
CloneTimeout time.Duration `mapstructure:"clone_timeout"`
|
||||
FetchTimeout time.Duration `mapstructure:"fetch_timeout"`
|
||||
PushTimeout time.Duration `mapstructure:"push_timeout"`
|
||||
OpsTimeout time.Duration `mapstructure:"ops_timeout"`
|
||||
}
|
||||
|
||||
// Git 控制 git CLI 二进制位置(默认 "git")。
|
||||
type Git struct {
|
||||
Binary string `mapstructure:"binary"`
|
||||
}
|
||||
|
||||
// Load 从(按优先级递增)默认值 → 配置文件(如有)→ 环境变量 加载配置。
|
||||
// configFile 可为空字符串,仅用环境变量。
|
||||
func Load(configFile string) (*Config, error) {
|
||||
@@ -61,6 +79,12 @@ func Load(configFile string) (*Config, error) {
|
||||
v.SetDefault("env", "development")
|
||||
v.SetDefault("data_dir", "./data")
|
||||
v.SetDefault("http.addr", ":8080")
|
||||
v.SetDefault("workspace.data_dir", "./data")
|
||||
v.SetDefault("workspace.clone_timeout", "30m")
|
||||
v.SetDefault("workspace.fetch_timeout", "5m")
|
||||
v.SetDefault("workspace.push_timeout", "5m")
|
||||
v.SetDefault("workspace.ops_timeout", "60s")
|
||||
v.SetDefault("git.binary", "git")
|
||||
|
||||
if configFile != "" {
|
||||
v.SetConfigFile(configFile)
|
||||
|
||||
Reference in New Issue
Block a user