configmap

package
v0.39.0 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewDynamicConfigHttpHandler

func NewDynamicConfigHttpHandler(configMap map[string]DynamicConfig) http.Handler

func ParseBool

func ParseBool(data map[string]string, key string, defaultValue bool) bool

func ParseDurationInSec

func ParseDurationInSec(data map[string]string, key string, defaultValue time.Duration) time.Duration

func ParseFloat64

func ParseFloat64(data map[string]string, key string, defaultValue float64) float64

func ParseInt64

func ParseInt64(data map[string]string, key string, defaultValue int64) int64

func ParseStringList

func ParseStringList(data map[string]string, key string, defaultValue []string) []string

Types

type ConfigMapper

type ConfigMapper func(rawCurrent map[string]string, previous *ConfigState) (interface{}, error)

ConfigMapper parses configmap data and returns user provided object or error

type ConfigMapperInput

type ConfigMapperInput struct {
	RawCurrent map[string]string
	Previous   ConfigState
}

type ConfigState

type ConfigState struct {
	Raw       map[string]string
	Mapped    interface{}
	Timestamp time.Time
}

type DynamicConfig

type DynamicConfig interface {
	// GetBootstrap returns the configuration state loaded on bootstrap. As bootstrap state never changes.
	GetBootstrap() interface{}

	// GetRawBootstrap returns the configmap loaded on bootstrap. As bootstrap state never changes.
	GetRawBootstrap() map[string]string

	// Get returns the latest configuration state
	Get() interface{}

	// GetRaw returns the latest configmap
	GetRaw() map[string]string

	// Close stops the internal refresh process
	Close()
}

func NewDynamicConfig

func NewDynamicConfig(config *rest.Config, configMapName string, configMapper ConfigMapper, options Options) (DynamicConfig, error)

func NewDynamicConfigFromMap

func NewDynamicConfigFromMap(data map[string]string, configMapper ConfigMapper, options Options) (DynamicConfig, error)

type OnErrorCallback

type OnErrorCallback func(err error, previous *ConfigState)

type OnUpdateCallback

type OnUpdateCallback func(current *ConfigState, previous *ConfigState)

type Options

type Options struct {
	// If set to true, load data during initialization only, and do not refresh them.
	DisableDynamicUpdates bool
	// Update callback is called on each data evaluation both successful and failed
	OnUpdateCallback OnUpdateCallback
	// Called when there is an during config data processing
	OnErrorCallback OnErrorCallback
	// Configuration template. If set, and configmap is not found, a new one is created using this template.
	// If configmap is there, but some parameters are missing, there are added with the default values.
	Template map[string]string
	// If set to true, unrecognized parameters are removed from a configmap
	RemoveUnknownProperties bool
}

Jump to

Keyboard shortcuts

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