MCPcopy Create free account
hub / github.com/astercloud/aster / LoadDefault

Function LoadDefault

pkg/config/loader.go:350–373  ·  view source on GitHub ↗

LoadDefault 从默认位置加载配置 查找顺序: 1. ./agent.yaml 2. ./config/agent.yaml 3. ~/.aster/agent.yaml

()

Source from the content-addressed store, hash-verified

348// 2. ./config/agent.yaml
349// 3. ~/.aster/agent.yaml
350func LoadDefault() (*types.AgentConfig, error) {
351 loader := NewLoader()
352
353 paths := []string{
354 "agent.yaml",
355 "agent.yml",
356 "config/agent.yaml",
357 "config/agent.yml",
358 }
359
360 // 添加用户目录
361 if home, err := os.UserHomeDir(); err == nil {
362 paths = append(paths, home+"/.aster/agent.yaml")
363 paths = append(paths, home+"/.aster/agent.yml")
364 }
365
366 for _, path := range paths {
367 if _, err := os.Stat(path); err == nil {
368 return loader.LoadAgentConfig(path)
369 }
370 }
371
372 return nil, fmt.Errorf("no default config file found in: %v", paths)
373}
374
375// MustLoad 必须成功加载配置,否则 panic
376func MustLoad(path string) *types.AgentConfig {

Callers

nothing calls this directly

Calls 3

LoadAgentConfigMethod · 0.95
NewLoaderFunction · 0.70
StatMethod · 0.65

Tested by

no test coverage detected