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)
| 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. |
| 286 | func 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 | |
| 310 | type dataDirType byte |
| 311 |
no test coverage detected