config

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FlagLogLevel  = "log-level"
	FlagLogFormat = "log-format"

	FlagRedisHost     = "redis-host"
	FlagRedisPort     = "redis-port"
	FlagRedisPassword = "redis-password"
	FlagRedisDB       = "redis-db"

	FlagHTTPTimeout  = "http-timeout"
	FlagUpdatesAddr  = "updates-addr"
	FlagUpdatesHost  = "updates-host"
	FlagDownloadAddr = "download-addr"
	FlagDownloadHost = "download-host"

	FlagAccountID  = "account-id"
	FlagLicenseKey = "license-key"

	FlagCacheDuration = "cache-duration"

	FlagDebugAddr = "debug-addr"

	FlagTranslateIngressNginxUrls = "translate-ingress-nginx-urls"
)
View Source
const EnvPrefix = "GEOIP_"
View Source
const LevelTrace = slog.Level(-5)

Variables

This section is empty.

Functions

func EnvName

func EnvName(name string) string

func InitLog added in v0.1.0

func InitLog(w io.Writer, level slog.Level, format LogFormat)

func LogFormatStrings added in v0.1.0

func LogFormatStrings() []string

LogFormatStrings returns a slice of all String values of the enum

func NewContext

func NewContext(ctx context.Context, conf *Config) context.Context

func RegisterCompletions

func RegisterCompletions(cmd *cobra.Command)

Types

type Config

type Config struct {
	RedisHost     string
	RedisPort     uint16
	RedisPassword string
	RedisDB       int

	HTTPTimeout  time.Duration
	UpdatesAddr  string
	UpdatesHost  string
	DownloadAddr string
	DownloadHost string

	AccountID  int
	LicenseKey string

	CacheDuration time.Duration

	DebugAddr string

	TranslateIngressNginxPaths bool
	// contains filtered or unexported fields
}

func FromContext

func FromContext(ctx context.Context) (*Config, bool)

func NewDefault

func NewDefault() *Config

func (*Config) InitLog added in v0.1.0

func (c *Config) InitLog(w io.Writer)

func (*Config) Load

func (c *Config) Load(cmd *cobra.Command) error

func (*Config) LogFormat

func (c *Config) LogFormat() (LogFormat, error)

func (*Config) LogLevel

func (c *Config) LogLevel() (slog.Level, error)

func (*Config) RegisterFlags

func (c *Config) RegisterFlags(cmd *cobra.Command)

type LogFormat added in v0.1.0

type LogFormat uint8
const (
	FormatAuto LogFormat = iota
	FormatColor
	FormatPlain
	FormatJSON
)

func LogFormatString added in v0.1.0

func LogFormatString(s string) (LogFormat, error)

LogFormatString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func LogFormatValues added in v0.1.0

func LogFormatValues() []LogFormat

LogFormatValues returns all values of the enum

func (LogFormat) IsALogFormat added in v0.1.0

func (i LogFormat) IsALogFormat() bool

IsALogFormat returns "true" if the value is listed in the enum definition. "false" otherwise

func (LogFormat) MarshalText added in v0.1.0

func (i LogFormat) MarshalText() ([]byte, error)

MarshalText implements the encoding.TextMarshaler interface for LogFormat

func (LogFormat) String added in v0.1.0

func (i LogFormat) String() string

func (*LogFormat) UnmarshalText added in v0.1.0

func (i *LogFormat) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface for LogFormat

Jump to

Keyboard shortcuts

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