config

package
v0.0.0-...-1f94361 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 13, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddCobraFlag

func AddCobraFlag(fs *pflag.FlagSet, ptype, name, defaultValue, help string)

AddCobraFlag creates a new flag and adds it to the flagSet

func BindCobraFlags

func BindCobraFlags(cmd *cobra.Command, v *viper.Viper, envPrefix string) error

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

func BindCobraFlagsToCmd(cmd *cobra.Command, flags interface{}) error

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 NewConfig

func NewConfig() *Config

NewConfig returns an instance of the Config

func (*Config) MarshalConfig

func (c *Config) MarshalConfig() string

MarshalConfig stringifies the configuration parameters while excluding sensitive ones

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL