configs

package
v0.0.0-...-187538d Latest Latest
Warning

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

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

Documentation

Overview

Package configs implements the configuration for the host.

Index

Constants

This section is empty.

Variables

View Source
var ErrConfigInvalidLogLevel = errors.New("config: invalid log level")

Functions

func AddCobraFlags

func AddCobraFlags(v *viper.Viper, cmd *cobra.Command, funcs ...func(*flag.FlagSet) error) error

AddCobraFlags adds flags to the viper and the cobra command.

func AddCobraPersistentFlags

func AddCobraPersistentFlags(v *viper.Viper, cmd *cobra.Command, funcs ...func(*flag.FlagSet) error) error

func AddFlag

func AddFlag[T any](v *viper.Viper, name string, value T, usage string) error

AddFlag adds a flag to the viper.

func AddFlagsForCommon

func AddFlagsForCommon(flagSet *flag.FlagSet) error

AddFlagsForCommon adds the common flags to the flag set.

func FlagName

func FlagName(flags ...string) string

FlagName returns the flag name.

func InitFromViperForCommon

func InitFromViperForCommon(v *viper.Viper) (bool, string, error)

InitFromViperForCommon initializes the common configuration from the viper.

func NewLogger

func NewLogger(debug bool, logLevel string) (*zap.Logger, error)

NewLogger creates a new logger.

func NewViper

func NewViper() (*viper.Viper, error)

NewViper creates a new viper.

func NewViperFromConfig

func NewViperFromConfig(onCreation func(*viper.Viper) error) (*viper.Viper, error)

NewViperFromConfig creates a new viper from the config.

func Viperize

func Viperize(funcs ...func(*flag.FlagSet) error) (*viper.Viper, *cobra.Command, error)

Viperize creates a new viper and a new cobra command.

Types

type Configurable

type Configurable interface {
	AddFlags(flagSet *flag.FlagSet) error
	InitFromViper(v *viper.Viper) error
}

Configurable means that the object can be configured.

Jump to

Keyboard shortcuts

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