Documentation
¶
Overview ¶
Package config contains the configuration for the minder cli and server
Index ¶
- func BindConfigFlag[V any](v *viper.Viper, flags *pflag.FlagSet, viperPath string, cmdLineArg string, ...) error
- func BindConfigFlagWithShort[V any](v *viper.Viper, flags *pflag.FlagSet, viperPath string, cmdLineArg string, ...) error
- func GetConfigFileData(cfgFilePath string) (interface{}, error)
- func GetKeysWithNullValueFromYAML(data interface{}, currentPath string) []string
- func ReadConfigFromViper[CFG any](v *viper.Viper) (*CFG, error)
- func ReadKey(keypath string) ([]byte, error)
- func RegisterDatabaseFlags(v *viper.Viper, flags *pflag.FlagSet) error
- func SetViperStructDefaults(v *viper.Viper, prefix string, s any)
- type DatabaseConfig
- type FlagInst
- type FlagInstShort
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BindConfigFlag ¶
func BindConfigFlag[V any]( v *viper.Viper, flags *pflag.FlagSet, viperPath string, cmdLineArg string, defaultValue V, help string, binder FlagInst[V], ) error
BindConfigFlag is a helper function that binds a configuration value to a flag.
Parameters: - v: The viper.Viper object used to retrieve the configuration value. - flags: The pflag.FlagSet object used to retrieve the flag value. - viperPath: The path used to retrieve the configuration value from Viper. - cmdLineArg: The flag name used to check if the flag has been set and to retrieve its value. - help: The help text for the flag. - defaultValue: A default value used to determine the type of the flag (string, int, etc.). - binder: A function that creates a flag and returns a pointer to the value.
func BindConfigFlagWithShort ¶
func BindConfigFlagWithShort[V any]( v *viper.Viper, flags *pflag.FlagSet, viperPath string, cmdLineArg string, short string, defaultValue V, help string, binder FlagInstShort[V], ) error
BindConfigFlagWithShort is a helper function that binds a configuration value to a flag.
Parameters: - v: The viper.Viper object used to retrieve the configuration value. - flags: The pflag.FlagSet object used to retrieve the flag value. - viperPath: The path used to retrieve the configuration value from Viper. - cmdLineArg: The flag name used to check if the flag has been set and to retrieve its value. - short: The short name for the flag. - help: The help text for the flag. - defaultValue: A default value used to determine the type of the flag (string, int, etc.). - binder: A function that creates a flag and returns a pointer to the value.
func GetConfigFileData ¶
GetConfigFileData returns the data from the given configuration file.
func GetKeysWithNullValueFromYAML ¶
GetKeysWithNullValueFromYAML returns a list of paths to null values in the given configuration data.
func ReadConfigFromViper ¶
ReadConfigFromViper reads the configuration from the given Viper instance. This will return the already-parsed and validated configuration, or an error.
func RegisterDatabaseFlags ¶
RegisterDatabaseFlags registers the flags for the database configuration
func SetViperStructDefaults ¶
SetViperStructDefaults recursively sets the viper default values for the given struct.
Per https://github.com/spf13/viper/issues/188#issuecomment-255519149, and https://github.com/spf13/viper/issues/761, we need to call viper.SetDefault() for each field in the struct to be able to use env var overrides. This also lets us use the struct as the source of default values, so yay?
Types ¶
type DatabaseConfig ¶
type DatabaseConfig struct {
Host string `mapstructure:"dbhost" default:"localhost"`
Port int `mapstructure:"dbport" default:"5432"`
User string `mapstructure:"dbuser" default:"postgres"`
Password string `mapstructure:"dbpass" default:"postgres"`
Name string `mapstructure:"dbname" default:"minder"`
SSLMode string `mapstructure:"sslmode" default:"disable"`
IdleConnections int `mapstructure:"idle_connections" default:"0"`
}
DatabaseConfig is the configuration for the database
func (*DatabaseConfig) GetDBConnection ¶
GetDBConnection returns a connection to the database
type FlagInstShort ¶
FlagInstShort is a function that creates a flag and returns a pointer to the value
Directories
¶
| Path | Synopsis |
|---|---|
|
Package client contains the configuration for the minder cli
|
Package client contains the configuration for the minder cli |
|
Package reminder contains configuration options for the reminder service.
|
Package reminder contains configuration options for the reminder service. |
|
Package server contains a centralized structure for all configuration options.
|
Package server contains a centralized structure for all configuration options. |