config

package
v1.4.2 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2022 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package config uses the exact same precedence order as Viper, where each item takes precedence over the item below it:

  • explicit call to Set (case insensitive)
  • flag (case insensitive)
  • env (case sensitive - see notes below)
  • config (case insensitive)
  • key/value store (case insensitive)
  • default (case insensitive)

Environment variable resolution is performed based on the following rules:

  • If the key contains only uppercase characters, numbers and underscores, the environment variable is looked up in its entirety, e.g. SOME_VARIABLE -> SOME_VARIABLE
  • In all other cases, the environment variable is transformed before being looked up as following: 1. camelCase is converted to snake_case, e.g. someVariable -> some_variable 2. dots (.) are replaced with underscores (_), e.g. some.variable -> some_variable 3. the resulting string is uppercased and prefixed with RSERVER_, e.g. some_variable -> RSERVER_SOME_VARIABLE

Index

Constants

View Source
const (
	EmbeddedMode       = "embedded"
	MasterMode         = "master"
	MasterSlaveMode    = "master_and_slave"
	SlaveMode          = "slave"
	OffMode            = "off"
	EmbeddedMasterMode = "embedded_master"
)

Rudder server supported config constants

Variables

This section is empty.

Functions

func ConfigKeyToEnv added in v1.2.0

func ConfigKeyToEnv(s string) string

ConfigKeyToEnv gets the env variable name from a given config key

func GetBool

func GetBool(key string, defaultValue bool) (value bool)

GetBool gets bool value from config

func GetDuration

func GetDuration(key string, defaultValueInTimescaleUnits int64, timeScale time.Duration) (value time.Duration)

GetDuration gets duration value from config

func GetFloat64

func GetFloat64(key string, defaultValue float64) (value float64)

GetFloat64 gets float64 value from config

func GetInstanceID added in v0.1.10

func GetInstanceID() string

func GetInt

func GetInt(key string, defaultValue int) (value int)

GetInt gets int value from config

func GetInt64

func GetInt64(key string, defaultValue int64) (value int64)

GetInt64 gets int64 value from config

func GetKubeNamespace added in v0.1.10

func GetKubeNamespace() string

GetKubeNamespace returns value stored in KUBE_NAMESPACE env var

func GetNamespaceIdentifier added in v0.1.10

func GetNamespaceIdentifier() string

GetNamespaceIdentifier

func GetReleaseName added in v0.1.10

func GetReleaseName() string

func GetString

func GetString(key, defaultValue string) (value string)

GetString gets string value from config

func GetWorkspaceToken

func GetWorkspaceToken() string

GetWorkspaceToken returns the workspace token provided in the environment variables Env variable CONFIG_BACKEND_TOKEN is deprecating soon WORKSPACE_TOKEN is newly introduced. This will override CONFIG_BACKEND_TOKEN

func IsSet added in v0.1.10

func IsSet(key string) bool

IsSet checks if config is set for a key

func MustGetInt added in v1.2.0

func MustGetInt(key string) (value int)

MustGetInt gets int value from config or panics if the config doesn't exist

func MustGetString added in v1.2.0

func MustGetString(key string) (value string)

MustGetString gets string value from config or panics if the config doesn't exist

func RegisterBoolConfigVariable added in v0.1.10

func RegisterBoolConfigVariable(defaultValue bool, ptr *bool, isHotReloadable bool, keys ...string)

RegisterBoolConfigVariable registers bool config variable

func RegisterDurationConfigVariable added in v0.1.10

func RegisterDurationConfigVariable(defaultValueInTimescaleUnits int64, ptr *time.Duration, isHotReloadable bool, timeScale time.Duration, keys ...string)

RegisterDurationConfigVariable registers duration config variable

func RegisterFloat64ConfigVariable added in v0.1.10

func RegisterFloat64ConfigVariable(defaultValue float64, ptr *float64, isHotReloadable bool, keys ...string)

RegisterFloat64ConfigVariable registers float64 config variable

func RegisterInt64ConfigVariable added in v0.1.10

func RegisterInt64ConfigVariable(defaultValue int64, ptr *int64, isHotReloadable bool, valueScale int64, keys ...string)

RegisterInt64ConfigVariable registers int64 config variable

func RegisterIntConfigVariable added in v0.1.10

func RegisterIntConfigVariable(defaultValue int, ptr *int, isHotReloadable bool, valueScale int, keys ...string)

RegisterIntConfigVariable registers int config variable

func RegisterStringConfigVariable added in v0.1.10

func RegisterStringConfigVariable(defaultValue string, ptr *string, isHotReloadable bool, keys ...string)

RegisterStringConfigVariable registers string config variable

func RegisterStringSliceConfigVariable added in v0.1.10

func RegisterStringSliceConfigVariable(defaultValue []string, ptr *[]string, isHotReloadable bool, keys ...string)

RegisterStringSliceConfigVariable registers string slice config variable

func Reset added in v1.2.0

func Reset()

Reset resets the default, singleton config instance. Shall only be used by tests, until we move to a proper DI framework

func Set added in v1.2.0

func Set(key string, value interface{})

Set override existing config

Types

type Config added in v1.2.0

type Config struct {
	// contains filtered or unexported fields
}

Config is the entry point for accessing configuration

var Default *Config

default, singleton config instance

func New added in v1.2.0

func New() *Config

New creates a new config instance

func (*Config) GetBool added in v1.2.0

func (c *Config) GetBool(key string, defaultValue bool) (value bool)

GetBool gets bool value from config

func (*Config) GetDuration added in v1.2.0

func (c *Config) GetDuration(key string, defaultValueInTimescaleUnits int64, timeScale time.Duration) (value time.Duration)

GetDuration gets duration value from config

func (*Config) GetFloat64 added in v1.2.0

func (c *Config) GetFloat64(key string, defaultValue float64) (value float64)

GetFloat64 gets float64 value from config

func (*Config) GetInt added in v1.2.0

func (c *Config) GetInt(key string, defaultValue int) (value int)

GetInt gets int value from config

func (*Config) GetInt64 added in v1.2.0

func (c *Config) GetInt64(key string, defaultValue int64) (value int64)

GetInt64 gets int64 value from config

func (*Config) GetString added in v1.2.0

func (c *Config) GetString(key, defaultValue string) (value string)

GetString gets string value from config

func (*Config) GetStringSlice added in v1.2.0

func (c *Config) GetStringSlice(key string, defaultValue []string) (value []string)

GetStringSlice gets string slice value from config

func (*Config) IsSet added in v1.2.0

func (c *Config) IsSet(key string) bool

IsSet checks if config is set for a key

func (*Config) MustGetInt added in v1.2.0

func (c *Config) MustGetInt(key string) (value int)

MustGetInt gets int value from config or panics if the config doesn't exist

func (*Config) MustGetString added in v1.2.0

func (c *Config) MustGetString(key string) (value string)

MustGetString gets string value from config or panics if the config doesn't exist

func (*Config) RegisterBoolConfigVariable added in v1.2.0

func (c *Config) RegisterBoolConfigVariable(defaultValue bool, ptr *bool, isHotReloadable bool, keys ...string)

RegisterBoolConfigVariable registers bool config variable

func (*Config) RegisterDurationConfigVariable added in v1.2.0

func (c *Config) RegisterDurationConfigVariable(defaultValueInTimescaleUnits int64, ptr *time.Duration, isHotReloadable bool, timeScale time.Duration, keys ...string)

RegisterDurationConfigVariable registers duration config variable

func (*Config) RegisterFloat64ConfigVariable added in v1.2.0

func (c *Config) RegisterFloat64ConfigVariable(defaultValue float64, ptr *float64, isHotReloadable bool, keys ...string)

RegisterFloat64ConfigVariable registers float64 config variable

func (*Config) RegisterInt64ConfigVariable added in v1.2.0

func (c *Config) RegisterInt64ConfigVariable(defaultValue int64, ptr *int64, isHotReloadable bool, valueScale int64, keys ...string)

RegisterInt64ConfigVariable registers int64 config variable

func (*Config) RegisterIntConfigVariable added in v1.2.0

func (c *Config) RegisterIntConfigVariable(defaultValue int, ptr *int, isHotReloadable bool, valueScale int, keys ...string)

RegisterIntConfigVariable registers int config variable

func (*Config) RegisterStringConfigVariable added in v1.2.0

func (c *Config) RegisterStringConfigVariable(defaultValue string, ptr *string, isHotReloadable bool, keys ...string)

RegisterStringConfigVariable registers string config variable

func (*Config) RegisterStringSliceConfigVariable added in v1.2.0

func (c *Config) RegisterStringSliceConfigVariable(defaultValue []string, ptr *[]string, isHotReloadable bool, keys ...string)

RegisterStringSliceConfigVariable registers string slice config variable

func (*Config) Set added in v1.2.0

func (c *Config) Set(key string, value interface{})

Set override existing config

Directories

Path Synopsis
Package backendconfig is a generated GoMock package.
Package backendconfig is a generated GoMock package.
internal/cache
Package cache is a generated GoMock package.
Package cache is a generated GoMock package.

Jump to

Keyboard shortcuts

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