dynamicconfig

package
v1.17.0 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2025 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const TableName = "cilium-configs"

Variables

View Source
var (
	ByKey = keyIndex.Query

	ByName = keyNameIndex.Query
)
View Source
var Cell = cell.Module(
	"cilium-agent-dynamic-config",
	"Reflects Cilium configuration to the DynamicConfig table",
	cell.ProvidePrivate(
		NewConfigTable,
		NewConfigMapReflector,
	),
	cell.Provide(
		statedb.RWTable[DynamicConfig].ToTable,
		func(c Config) ConfigSource { return c },
	),
	cell.Invoke(
		RegisterConfigMapReflector,
	),
	cell.Config(defaultConfig),
)

Cell provides a reflector of cilium configs to DynamicConfigMap table. It provides read-only Table[DynamicConfig] and Get/Watch for config keys.

Usage: cell.Module(

	...
 cell.Invoke(
		func(t statedb.Table[DynamicConfig], db *statedb.DB) {
			c, f := dynamicconfig.GetKey(db.ReadTxn(), t, "KEY")

			c, f, w := dynamicconfig.WatchKey(db.ReadTxn(), t, "KEY")
		},
	),
	...

)

Functions

func NewConfigTable

func NewConfigTable(db *statedb.DB) (statedb.RWTable[DynamicConfig], error)

func RegisterConfigMapReflector

func RegisterConfigMapReflector(jobGroup job.Group, db *statedb.DB, rcs []k8s.ReflectorConfig[DynamicConfig], c Config) error

func WatchAllKeys

func WatchAllKeys(txn statedb.ReadTxn, table statedb.Table[DynamicConfig]) (map[string]DynamicConfig, <-chan struct{})

WatchAllKeys retrieves all DynamicConfig values accounting for priority when the key is present in multiple config sources.

Types

type Config

type Config struct {
	EnableDynamicConfig    bool
	ConfigSources          string
	ConfigSourcesOverrides string
}

func (Config) Flags

func (c Config) Flags(flags *pflag.FlagSet)

func (Config) IsKindNodeConfig

func (c Config) IsKindNodeConfig() bool

type ConfigSource

type ConfigSource interface {
	IsKindNodeConfig() bool
}

type DynamicConfig

type DynamicConfig struct {
	Key      Key
	Value    string
	Priority int
}

func GetKey

func GetKey(txn statedb.ReadTxn, table statedb.Table[DynamicConfig], key string) (DynamicConfig, bool)

GetKey retrieves a DynamicConfig value accounting for the priority when the key is present in multiple config sources. It returns the DynamicConfig value associated with the key, if found and boolean indicating whether the key was found or not.

func WatchKey

func WatchKey(txn statedb.ReadTxn, table statedb.Table[DynamicConfig], key string) (DynamicConfig, bool, <-chan struct{})

WatchKey retrieves a DynamicConfig value accounting for priority when the key is present in multiple config sources. It returns the DynamicConfig value associated with the key, if found, a boolean indicating whether the key was found or not, and a watch channel that is closed if the entry is invalidated.

func (DynamicConfig) TableHeader

func (d DynamicConfig) TableHeader() []string

func (DynamicConfig) TableRow

func (d DynamicConfig) TableRow() []string

type Key

type Key struct {
	Name   string
	Source string
}

func (Key) String

func (k Key) String() string

Jump to

Keyboard shortcuts

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