(file string)
| 131 | } |
| 132 | |
| 133 | func LoadConfiguration(file string) Config { |
| 134 | //Loads a default config from adapter_config in case a custom adapter isn't provided by the client. |
| 135 | //DriverName, ConnectionString, and dbSpecified can be configured in the file. Defaults to 'file' mode. |
| 136 | |
| 137 | configFile, err := os.Open(file) |
| 138 | if err != nil { |
| 139 | fmt.Println(err.Error()) |
| 140 | } |
| 141 | decoder := json.NewDecoder(configFile) |
| 142 | config := Config{} |
| 143 | decoder.Decode(&config) |
| 144 | re := regexp.MustCompile(`\$\b((\w*))\b`) |
| 145 | config.Connection = re.ReplaceAllStringFunc(config.Connection, func(s string) string { |
| 146 | return os.Getenv(strings.TrimPrefix(s, `$`)) |
| 147 | }) |
| 148 | |
| 149 | return config |
| 150 | } |
| 151 | |
| 152 | type Config struct { |
| 153 | Driver string |
no outgoing calls
no test coverage detected