MCPcopy Create free account
hub / github.com/MiniCodeMonkey/chief / Load

Function Load

internal/config/config.go:54–71  ·  view source on GitHub ↗

Load reads the config from .chief/config.yaml. Returns Default() when the file doesn't exist (no error).

(baseDir string)

Source from the content-addressed store, hash-verified

52// Load reads the config from .chief/config.yaml.
53// Returns Default() when the file doesn't exist (no error).
54func Load(baseDir string) (*Config, error) {
55 path := configPath(baseDir)
56
57 data, err := os.ReadFile(path)
58 if err != nil {
59 if os.IsNotExist(err) {
60 return Default(), nil
61 }
62 return nil, err
63 }
64
65 cfg := Default()
66 if err := yaml.Unmarshal(data, cfg); err != nil {
67 return nil, err
68 }
69
70 return cfg, nil
71}
72
73// Save writes the config to .chief/config.yaml.
74func Save(baseDir string, cfg *Config) error {

Callers 5

NewAppWithOptionsFunction · 0.92
TestResolve_configFileFunction · 0.92
resolveProviderFunction · 0.92
TestLoadNonExistentFunction · 0.85
TestSaveAndLoadFunction · 0.85

Calls 2

configPathFunction · 0.85
DefaultFunction · 0.85

Tested by 3

TestResolve_configFileFunction · 0.74
TestLoadNonExistentFunction · 0.68
TestSaveAndLoadFunction · 0.68