configloader

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2022 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config map[string]interface{}

Config is a dynamic config value.

type ConfigManager

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

ConfigManager manages ConfigLoaders and merges structured configuration values from multiple sources. The order in which the configurations are merged are based on the order of when each Loader is added to the ConfigManager.

func NewConfigManager

func NewConfigManager() *ConfigManager

func (*ConfigManager) AddConfigLoaders

func (c *ConfigManager) AddConfigLoaders(loader ...Loader)

func (*ConfigManager) LoadAndUnmarshalConfig

func (c *ConfigManager) LoadAndUnmarshalConfig(configName configv1alpha1.ConfigName, out interface{}) error

LoadAndUnmarshalConfig will load and unmarshal the given config name into out.

If an error is encountered, it will return a previously known good value if available, and log the error. Otherwise, if there is no previously cached value for configName, then the error will be propagated back to the caller.

func (*ConfigManager) Start

func (c *ConfigManager) Start(ctx context.Context) error

type ConfigMapLoader

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

ConfigMapLoader is a dynamic Loader that starts an informer to watch changes on a ConfigMap with a specific name and namespace. Supports loading both JSON and YAML configuration.

func NewConfigMapLoader

func NewConfigMapLoader(client kubernetes.Interface, namespace, name string) *ConfigMapLoader

func (*ConfigMapLoader) Load

func (c *ConfigMapLoader) Load(configName configv1alpha1.ConfigName) (Config, error)

Load returns the unmarshaled config data stored in a given ConfigMap. If the ConfigMap or config name in the ConfigMap does not exist, an empty config will be returned.

func (*ConfigMapLoader) Name

func (c *ConfigMapLoader) Name() string

func (*ConfigMapLoader) Start

func (c *ConfigMapLoader) Start(ctx context.Context) error

type DefaultsLoader

type DefaultsLoader struct {

	// Can override defaults here, but they are not expected to reload after Start()
	// is called. Exposed for unit tests.
	Defaults map[configv1alpha1.ConfigName]runtime.Object
	// contains filtered or unexported fields
}

DefaultsLoader is a simple Loader that populates hardcoded defaults. This is intended to be a fallback when all configs are not populated.

func NewDefaultsLoader

func NewDefaultsLoader() *DefaultsLoader

func (*DefaultsLoader) Load

func (d *DefaultsLoader) Load(configName configv1alpha1.ConfigName) (Config, error)

func (*DefaultsLoader) Name

func (d *DefaultsLoader) Name() string

func (*DefaultsLoader) Start

func (d *DefaultsLoader) Start(_ context.Context) error

type Loader

type Loader interface {
	Name() string
	Start(context.Context) error
	Load(configName configv1alpha1.ConfigName) (Config, error)
}

Loader knows how to loads a Config given a config name.

type SecretLoader

type SecretLoader struct {
	*ConfigMapLoader
}

SecretLoader is a dynamic Loader that starts an informer to watch changes on a Secret with a specific name and namespace. Supports loading both JSON and YAML configuration.

func NewSecretLoader

func NewSecretLoader(client kubernetes.Interface, namespace, name string) *SecretLoader

func (*SecretLoader) Name

func (c *SecretLoader) Name() string

func (*SecretLoader) Start

func (c *SecretLoader) Start(ctx context.Context) error

Jump to

Keyboard shortcuts

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