frostfs-node/cmd/internal/common/config/opts.go

50 lines
1003 B
Go

package config
import "github.com/spf13/viper"
type opts struct {
path string
configDir string
envPrefix string
v *viper.Viper
}
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
}
}
// WithViper returns an option to defines
// a predefined viper.Viper.
func WithViper(v *viper.Viper) Option {
return func(o *opts) {
o.v = v
}
}