MCPcopy Create free account
hub / github.com/dolthub/doltgresql / loadServerConfig

Function loadServerConfig

cmd/doltgres/main.go:286–308  ·  view source on GitHub ↗

loadServerConfig loads server configuration in the following order: 1. If the --config flag is provided, loads the config from the file at the path provided, or returns an errors if it cannot. 2. If the default config file config.yaml exists, attempts to load it, but doesn't return an error if it do

(params map[string]*string, fs filesys.Filesys)

Source from the content-addressed store, hash-verified

284// The second result param is a boolean indicating whether a file was loaded, since we vary later initialization
285// behavior depending on whether we loaded a config file from disk.
286func loadServerConfig(params map[string]*string, fs filesys.Filesys) (*servercfg.DoltgresConfig, bool, error) {
287 configFilePath, configFilePathSpecified := paramVal(params, configParam)
288
289 if configFilePathSpecified {
290 cfgPathExists, isDir := fs.Exists(configFilePath)
291 if !cfgPathExists {
292 return nil, false, errors.Errorf("config file not found at %s", configFilePath)
293 } else if isDir {
294 return nil, false, errors.Errorf("cannot use directory %s for config file", configFilePath)
295 }
296
297 cfg, err := servercfg.ReadConfigFromYamlFile(fs, configFilePath)
298 return cfg, true, err
299 } else {
300 cfgPathExists, isDir := fs.Exists(defaultCfgFile)
301 if cfgPathExists && !isDir {
302 cfg, err := servercfg.ReadConfigFromYamlFile(fs, defaultCfgFile)
303 return cfg, true, err
304 }
305 }
306
307 return servercfg.DefaultServerConfig(), false, nil
308}
309
310type dataDirType byte
311

Callers 1

mainFunction · 0.85

Calls 5

ReadConfigFromYamlFileFunction · 0.92
DefaultServerConfigFunction · 0.92
paramValFunction · 0.85
ExistsMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected