forked from TrueCloudLab/frostfs-node
[#125] node: Move viper creation to internal/common/config
Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>
This commit is contained in:
parent
b2123bfd1a
commit
d390f093e0
9 changed files with 101 additions and 76 deletions
38
cmd/internal/common/config/opts.go
Normal file
38
cmd/internal/common/config/opts.go
Normal file
|
@ -0,0 +1,38 @@
|
|||
package config
|
||||
|
||||
type Opts struct {
|
||||
Path string
|
||||
ConfigDir string
|
||||
EnvPrefix string
|
||||
}
|
||||
|
||||
func DefaultOpts() *Opts {
|
||||
return new(Opts)
|
||||
}
|
||||
|
||||
// Option allows to set an optional parameter of the Config.
|
||||
type Option func(*Opts)
|
||||
|
||||
// WithConfigFile returns an option to set the system path
|
||||
// to the configuration file.
|
||||
func WithConfigFile(path string) Option {
|
||||
return func(o *Opts) {
|
||||
o.Path = path
|
||||
}
|
||||
}
|
||||
|
||||
// WithConfigDir returns an option to set the system path
|
||||
// to the directory with configuration files.
|
||||
func WithConfigDir(path string) Option {
|
||||
return func(o *Opts) {
|
||||
o.ConfigDir = path
|
||||
}
|
||||
}
|
||||
|
||||
// WithEnvPrefix returns an option to defines
|
||||
// a prefix that ENVIRONMENT variables will use.
|
||||
func WithEnvPrefix(envPrefix string) Option {
|
||||
return func(o *Opts) {
|
||||
o.EnvPrefix = envPrefix
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue