Documentation
¶
Index ¶
- func AddCobraFlag(fs *pflag.FlagSet, ptype, name, defaultValue, help string)
- func BindCobraFlags(cmd *cobra.Command, v *viper.Viper, envPrefix string) error
- func BindCobraFlagsToCmd(cmd *cobra.Command, flags interface{}) error
- func DecodeSliceHook() mapstructure.DecodeHookFuncType
- func GetViper(configFileName, envPrefix, envType string, allowEmpty, autoEnv, quiet bool) (*viper.Viper, error)
- type Config
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddCobraFlag ¶
AddCobraFlag creates a new flag and adds it to the flagSet
func BindCobraFlags ¶
BindCobraFlags offers the integration between Cobra and Viper, through binding of the flags defined in a *cobra.Command to the corresponding configuration set to *viper.Viper
func BindCobraFlagsToCmd ¶
BindCobraFlagsToCmd creates the command-line flags based on the configuration parameters, and binds them to the Cobra command & the Viper instance
func DecodeSliceHook ¶
func DecodeSliceHook() mapstructure.DecodeHookFuncType
DecodeSliceHook performs the parsing of a []string flag during the unmarshaling process of Viper
func GetViper ¶
func GetViper(configFileName, envPrefix, envType string, allowEmpty, autoEnv, quiet bool) (*viper.Viper, error)
GetViper sets up the Viper boilerplate configuration. i.e. reads the config from configFileName, sets the environment variables' prefix to envPrefix and the environment file type to envType; returns a pointer to (already set up) Viper.
Types ¶
type Config ¶
type Config struct { LogLevel string `` /* 180-byte string literal not displayed */ ServerAddress string `` /* 158-byte string literal not displayed */ ServerPort string `` /* 141-byte string literal not displayed */ ShutDownTimeout int `` /* 157-byte string literal not displayed */ CORSAllowOrigins []string `` /* 146-byte string literal not displayed */ CORSAllowMethods []string `` /* 165-byte string literal not displayed */ CORSAllowHeaders []string `` /* 165-byte string literal not displayed */ CORSExposeHeaders []string `` /* 163-byte string literal not displayed */ CORSAllowCredentials bool `` /* 162-byte string literal not displayed */ CORSMaxAge int `` /* 147-byte string literal not displayed */ }
Config is the object that holds all the configuration parameters of the server, and holds all the information necessary to create command-line flags for them
func (*Config) MarshalConfig ¶
MarshalConfig stringifies the configuration parameters while excluding sensitive ones