frostfs-node/cmd/internal/common/config/opts.go
Anton Nikiforov d390f093e0 [#125] node: Move viper creation to internal/common/config
Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>
2023-04-26 13:53:51 +03:00

38 lines
795 B
Go

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
}
}