Documentation ¶
Index ¶
- func Bind[T any](c *T, prefix string, v *viper.Viper) *T
- func LoadRemoteSecret(name string) (string, error)
- type Binder
- type Cache
- type CmdBinder
- type Configurable
- type Configuration
- func (c *Configuration) Bind(_ string, v *viper.Viper)
- func (c *Configuration) Core() *Configuration
- func (c *Configuration) Load(cmd *cobra.Command, config any, environment string) error
- func (c *Configuration) Loaded(*Configuration)
- func (c *Configuration) Ready() bool
- func (c *Configuration) SetConfigDirName(dirName string)
- func (c *Configuration) SetConfigFile(path string)
- func (c *Configuration) SetConfigName(name string)
- func (c *Configuration) Validate(validate *validation.Validate) error
- type Validatable
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoadRemoteSecret ¶
LoadRemoteSecret loads a remote secret from configuration provided in environment variable.
Environment variable name is expected to be in the format:
<name>_FILE - path to the file containing the secret
Types ¶
type Binder ¶
Binder is an interface that can be implemented by configuration sections to bind to configuration file.
type Cache ¶
type Cache struct { Type cache.Type `mapstructure:"type" validate:"required,oneof=memory redis redis-cluster"` TTL time.Duration `mapstructure:"ttl" validate:"omitempty,min=0"` ConnectionString string `mapstructure:"connection" validate:"omitempty"` Password string `mapstructure:"password" validate:"omitempty"` KeyPrefix string `mapstructure:"key_prefix" validate:"omitempty"` }
type CmdBinder ¶ added in v0.3.0
CmdBinder is an interface that can be implemented by configuration sections to bind to command line arguments.
type Configurable ¶
type Configurable interface { Core() *Configuration Loaded(conf *Configuration) }
Configurable is an interface that can be implemented by extended configuration.
type Configuration ¶
type Configuration struct { // Cache configuration section. Cache *Cache // contains filtered or unexported fields }
Configuration for the application.
func (*Configuration) Bind ¶
func (c *Configuration) Bind(_ string, v *viper.Viper)
Bind binds configuration section to viper.
func (*Configuration) Core ¶
func (c *Configuration) Core() *Configuration
Core returns the core configuration.
func (*Configuration) Loaded ¶
func (c *Configuration) Loaded(*Configuration)
Loaded receives loaded core configuration.
func (*Configuration) Ready ¶
func (c *Configuration) Ready() bool
Ready returns true if the configuration has been loaded.
func (*Configuration) SetConfigDirName ¶
func (c *Configuration) SetConfigDirName(dirName string)
SetConfigDirName sets the name of the directory where the config file is located under common config locations.
func (*Configuration) SetConfigFile ¶
func (c *Configuration) SetConfigFile(path string)
SetConfigFile explicitly defines the path, name and extension of the config file.
func (*Configuration) SetConfigName ¶
func (c *Configuration) SetConfigName(name string)
SetConfigName sets name for the config file. Does not include extension.
func (*Configuration) Validate ¶
func (c *Configuration) Validate(validate *validation.Validate) error
Validate the configuration.
type Validatable ¶
type Validatable interface {
Validate(v *validation.Validate) error
}
Validatable is an interface that can be implemented by configuration section to validate the configuration.