config

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RetryLimitDefault   = 5
	RetryDelayDefault   = 10 * time.Second
	ConfSourceDefault   = ConfSourceEnv
	SecretSourceDefault = SecretSourceEnv
	LogFormatDefault    = logger.LogFormatText
	LogLevelDefault     = logger.LogLevelInfo

	ConfSourceEnv  = "env"
	ConfSourceYAML = "yaml"
	ConfSourceJSON = "json"

	KeyRetryDelay     = "retryDelay"
	KeyRetryLimit     = "retryLimit"
	KeyURL            = "url"
	KeySecretSource   = "secretSource"
	KeySecretFilename = "secretFilename"
	KeyLogFormat      = "logFormat"
	KeyLogLevel       = "logLevel"

	EnvRetryDelay     = "GOWAIT_RETRY_DELAY"
	EnvRetryLimit     = "GOWAIT_RETRY_LIMIT"
	EnvURL            = "GOWAIT_URL"
	EnvSecretSource   = "GOWAIT_SECRET_SOURCE"
	EnvSecretFilename = "GOWAIT_SECRET_FILENAME"
	EnvSecret         = "GOWAIT_SECRET"
	EnvLogFormat      = "GOWAIT_LOG_FORMAT"
	EnvLogLevel       = "GOWAIT_LOG_LEVEL"

	SecretSourceEnv  = "env"
	SecretSourceFile = "file"
)

Variables

Functions

func ReadEnvironmentVariables

func ReadEnvironmentVariables(cm configmap.ConfigMap)

Types

type AppConfig

type AppConfig struct {
	Url            url.URL       `yaml:"url" json:"url"`
	ConfigSource   string        `yaml:"-" json:"-"`
	ConfigFilename string        `yaml:"-" json:"-"`
	Secret         string        `yaml:"-" json:"-"`
	SecretSource   string        `yaml:"secretSource" json:"secretSource"`
	SecretFilename string        `yaml:"secretFilename" json:"secretFilename"`
	LogFormat      string        `yaml:"logFormat" json:"logFormat"`
	LogLevel       string        `yaml:"logLevel" json:"logLevel"`
	RetryDelay     time.Duration `yaml:"retryDelay" json:"retryDelay"`
	RetryLimit     int           `yaml:"retryLimit" json:"retryLimit"`
}

AppConfig represents the struct of application configuration info

func (*AppConfig) LoadFromConfigMap

func (ac *AppConfig) LoadFromConfigMap(cm configmap.ConfigMap) error

func (*AppConfig) LoadFromJSON

func (ac *AppConfig) LoadFromJSON(fileName string) error

func (*AppConfig) LoadFromYAML

func (ac *AppConfig) LoadFromYAML(fileName string) error

func (*AppConfig) LoadSecret

func (ac *AppConfig) LoadSecret()

func (*AppConfig) PopulateFromAppConfigFile

func (ac *AppConfig) PopulateFromAppConfigFile(fileCfg *AppConfigFile) error

type AppConfigFile

type AppConfigFile struct {
	Url            string `yaml:"url" json:"url"`
	RetryDelay     string `yaml:"retryDelay" json:"retryDelay"`
	SecretSource   string `yaml:"secretSource" json:"secretSource"`
	SecretFilename string `yaml:"secretFilename" json:"secretFilename"`
	LogFormat      string `yaml:"logFormat" json:"logFormat"`
	LogLevel       string `yaml:"logLevel" json:"logLevel"`
	RetryLimit     int    `yaml:"retryLimit" json:"retryLimit"`
}

AppConfigFile represents the configuration struct in a flat file

Jump to

Keyboard shortcuts

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