env

package
v0.24.2 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2022 License: Apache-2.0, BSD-3-Clause, MIT Imports: 14 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreatePFlags

func CreatePFlags(set *pflag.FlagSet, value interface{})

CreatePFlags Creates pflags for the value structure and adds them in the provided set

func CreatePFlagsForConfigFile

func CreatePFlagsForConfigFile(set *pflag.FlagSet)

CreatePFlagsForConfigFile creates pflags for setting the configuration file

func EmptyFlagSet

func EmptyFlagSet() *pflag.FlagSet

EmptyFlagSet creates an empty flag set and adds the default set of flags to it

Types

type Environment

type Environment interface {
	Get(key string) interface{}
	Set(key string, value interface{})
	Unmarshal(value interface{}) error
	BindPFlag(key string, flag *pflag.Flag) error
	AllSettings() map[string]interface{}
}

Environment represents an abstraction over the env from which Service Manager configuration will be loaded

func DefaultLogger added in v0.18.7

func DefaultLogger(ctx context.Context, additionalPFlags ...func(set *pflag.FlagSet)) (Environment, error)

DefaultLogger creates a default environment that can be used to boot up a Service Manager

type File

type File struct {
	Name     string `description:"name of the configuration file"`
	Location string `description:"location of the configuration file"`
	Format   string `description:"extension of the configuration file"`
}

File describes the name, path and the format of the file to be used to load the configuration in the env

func DefaultConfigFile

func DefaultConfigFile() File

DefaultConfigFile holds the default SM config file properties

type ViperEnv

type ViperEnv struct {
	*viper.Viper
}

ViperEnv represents an implementation of the Environment interface that uses viper

func New

func New(ctx context.Context, set *pflag.FlagSet, onConfigChangeHandlers ...func(env Environment) func(event fsnotify.Event)) (*ViperEnv, error)

New creates a new environment. It accepts a flag set that should contain all the flags that the environment should be aware of.

func (*ViperEnv) AllSettings added in v0.8.0

func (v *ViperEnv) AllSettings() map[string]interface{}

func (*ViperEnv) Unmarshal

func (v *ViperEnv) Unmarshal(value interface{}) error

Unmarshal exposes viper's Unmarshal. Prior to unmarshaling it creates the necessary pflag and env var bindings so that pflag / env var values are also used during the unmarshaling.

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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