(configPath string, defaultDBPath string)
| 44 | } |
| 45 | |
| 46 | func (parser *parser) parseConfigFile(configPath string, defaultDBPath string) (*config, error) { |
| 47 | lines, err := parser.readConfigFile(configPath, 0) |
| 48 | if err != nil { |
| 49 | return nil, err |
| 50 | } |
| 51 | |
| 52 | confMap := createConfigMap(lines) |
| 53 | |
| 54 | dbPath, ok := confMap.Get("options", "DBPath") |
| 55 | if !ok { |
| 56 | dbPath = defaultDBPath |
| 57 | } |
| 58 | server, ok := confMap.Get(repository, "Server") |
| 59 | if !ok { |
| 60 | return nil, errors.New("server not found") |
| 61 | } |
| 62 | return &config{ |
| 63 | dbPath: dbPath, |
| 64 | server: server, |
| 65 | }, nil |
| 66 | } |
| 67 | |
| 68 | func (parser *parser) readConfigFile(fileName string, depth int) ([]string, error) { |
| 69 | if depth >= configMaxRecursion { |
no test coverage detected