forked from TrueCloudLab/frostfs-node
7e11bf9a55
Create `config` package nearby storage node application. Implement `Config` as a wrapper over `viper.Viper` that provides the minimum functionality required by the application. The constructor allows you to read the config from the file. Methods are provided for reading subsections and values from the config tree. Helper functions are implemented to cast a value to native Go types. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
20 lines
351 B
Go
20 lines
351 B
Go
package config
|
|
|
|
type opts struct {
|
|
path string
|
|
}
|
|
|
|
func defaultOpts() *opts {
|
|
return new(opts)
|
|
}
|
|
|
|
// Option allows to set optional parameter of the Config.
|
|
type Option func(*opts)
|
|
|
|
// WithConfigFile returns option to set system path
|
|
// to the configuration file.
|
|
func WithConfigFile(path string) Option {
|
|
return func(o *opts) {
|
|
o.path = path
|
|
}
|
|
}
|