MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / ReadInConfig

Method ReadInConfig

pkg/config/config.go:267–288  ·  view source on GitHub ↗

ReadInConfig will read in all defined config files (according to the config file flag set by WithConfigFileFlag). The parsed config files will be merged into the config struct.

()

Source from the content-addressed store, hash-verified

265// ReadInConfig will read in all defined config files (according to the config file flag set by WithConfigFileFlag).
266// The parsed config files will be merged into the config struct.
267func (m *Manager) ReadInConfig() error {
268 files := m.viper.GetStringSlice(m.configFlag)
269 // read config files in reverse order, so config files listed first take precedence
270 for index := len(files) - 1; index >= 0; index-- {
271 file := files[index]
272
273 // ignore default config files that are missing or do not have read permissions
274 if m.isDefault(file) && !m.inCLIFlags(file) {
275 if _, err := os.Stat(file); os.IsNotExist(err) || os.IsPermission(err) {
276 continue
277 }
278 }
279
280 m.viper.SetConfigFile(file)
281 err := m.viper.MergeInConfig()
282 if err != nil {
283 return err
284 }
285 }
286
287 return nil
288}
289
290// mergeConfig merges the config from the reader as a yml config file.
291func (m *Manager) mergeConfig(in io.Reader) error {

Callers 5

TestReadSingleConfigFunction · 0.80
TestReadMultiConfigFunction · 0.80
example.goFile · 0.80
root.goFile · 0.80
preRunFunction · 0.80

Calls 2

isDefaultMethod · 0.95
inCLIFlagsMethod · 0.95

Tested by 2

TestReadSingleConfigFunction · 0.64
TestReadMultiConfigFunction · 0.64