MCPcopy Create free account
hub / github.com/alibaba/open-code-review / LoadAppConfig

Function LoadAppConfig

cmd/opencodereview/config_cmd.go:259–272  ·  view source on GitHub ↗

LoadAppConfig loads config from path. Returns nil, nil if file does not exist.

(path string)

Source from the content-addressed store, hash-verified

257
258// LoadAppConfig loads config from path. Returns nil, nil if file does not exist.
259func LoadAppConfig(path string) (*Config, error) {
260 data, err := os.ReadFile(path)
261 if err != nil {
262 if os.IsNotExist(err) {
263 return nil, nil
264 }
265 return nil, fmt.Errorf("read app config %s: %w", path, err)
266 }
267 var cfg Config
268 if err := json.Unmarshal(data, &cfg); err != nil {
269 return nil, fmt.Errorf("parse app config: %w", err)
270 }
271 return &cfg, nil
272}
273
274func setConfigValue(cfg *Config, key, value string) error {
275 // Handle providers.<name>.<field> paths.

Callers 4

loadLLMRuntimeFunction · 0.85
runLLMTestFunction · 0.85

Calls

no outgoing calls

Tested by 2