config

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2020 License: Apache-2.0 Imports: 12 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddSetting

func AddSetting(name string, defValue interface{}, validationFn []ValidationFnType, callbackFn []SetFn) *setting

AddSetting returns a filled struct of ConfigSetting takes the config name and default value as arguments

func AllConfigKeys

func AllConfigKeys() []string

AllConfigKeys returns all the known config keys A known config key is one which was registered through AddSetting - config keys with a default value - config keys with a value set - config keys with no value set

func BindFlag

func BindFlag(key string, flag *pflag.Flag) error

BindFlags binds flags to config properties

func BindFlagSet

func BindFlagSet(flagSet *pflag.FlagSet) error

BindFlagset binds a flagset to their respective config properties

func ChangedConfigs

func ChangedConfigs() map[string]interface{}

ChangedConfigs returns all the changed config keys/values 'changed' means config keys with a value set either because they are set in the config file, or because they were changed at runtime. This does not include config keys with no default value, or with a default value

func EnsureConfigFileExists

func EnsureConfigFileExists() error

EnsureConfigFileExists creates the viper config file if it does not exists

func Get

func Get(key string) (interface{}, error)

func GetBool

func GetBool(key string) bool

GetBool returns the value of a boolean config key

func GetInt

func GetInt(key string) int

GetInt return the value of a key in int

func GetString

func GetString(key string) string

GetString return the value of a key in string

func InitViper

func InitViper() error

InitViper initializes viper

func RequiresRestartMsg

func RequiresRestartMsg(key, _ string) string

func Set

func Set(key string, value interface{}) (string, error)

Set sets the value for a give config key

func SetDefaults

func SetDefaults()

func SuccessfullyApplied

func SuccessfullyApplied(key, value string) string

func Unset

func Unset(key string) (string, error)

Unset unsets a given config key

func ValidateBool

func ValidateBool(value interface{}) (bool, string)

ValidateBool is a fail safe in the case user makes a typo for boolean config values

func ValidateBundle

func ValidateBundle(value interface{}) (bool, string)

ValidateBundle checks if provided bundle path is valid

func ValidateCPUs

func ValidateCPUs(value interface{}) (bool, string)

ValidateCPUs checks if provided cpus count is valid in the config

func ValidateIpAddress

func ValidateIpAddress(value interface{}) (bool, string)

ValidateIP checks if provided IP is valid

func ValidateMemory

func ValidateMemory(value interface{}) (bool, string)

ValidateMemory checks if provided memory is valid in the config

func ValidateNoProxy

func ValidateNoProxy(value interface{}) (bool, string)

ValidateNoProxy checks if the NoProxy string has the correct format

func ValidatePath

func ValidatePath(value interface{}) (bool, string)

ValidatePath checks if provided path is exist

func ValidateURI

func ValidateURI(value interface{}) (bool, string)

ValidateURI checks if given URI is valid

func WriteConfig

func WriteConfig() error

WriteConfig write config to file

Types

type SetFn

type SetFn func(string, string) string

type ValidationFnType

type ValidationFnType func(interface{}) (bool, string)

validationFnType takes the key, value as args and checks if valid

Jump to

Keyboard shortcuts

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