Documentation ¶
Index ¶
- Constants
- Variables
- func ErrNoContext(name string) error
- func IsErrConfigNotApplicable(err error) bool
- func IsErrNoContext(err error) bool
- func IsGeneric(cfg Config) bool
- func NewStrictConfigTypeScheme(base ...ConfigTypeScheme) runtime.VersionedTypeRegistry[Config, ConfigType]
- type AppliedConfig
- type AppliedConfigSelector
- type AppliedConfigSelectorFunction
- type AppliedConfigs
- type Builder
- func (b Builder) Bound() (Context, context.Context)
- func (b Builder) New(m ...datacontext.BuilderMode) Context
- func (b Builder) WithConfigTypeScheme(scheme ConfigTypeScheme) Builder
- func (b Builder) WithContext(ctx context.Context) Builder
- func (b Builder) WithSharedAttributes(ctx datacontext.AttributesContext) Builder
- type Config
- type ConfigApplier
- type ConfigApplierFunction
- type ConfigDecoder
- type ConfigSelector
- type ConfigSelectorFunction
- type ConfigSet
- type ConfigStore
- func (c *ConfigStore) AddSet(name string, set *ConfigSet)
- func (s *ConfigStore) Apply(c Config, desc string)
- func (s *ConfigStore) Generation() int64
- func (c *ConfigStore) GetConfigForName(ctx Context, name string, selector AppliedConfigSelector) (int64, AppliedConfigs)
- func (c *ConfigStore) GetConfigForSelector(ctx Context, selector AppliedConfigSelector) (int64, AppliedConfigs)
- func (c *ConfigStore) GetConfigForType(ctx Context, typ string, selector AppliedConfigSelector) (int64, AppliedConfigs)
- func (c *ConfigStore) GetSet(name string) *ConfigSet
- func (s *ConfigStore) Reset() int64
- type ConfigType
- type ConfigTypeProvider
- type ConfigTypeScheme
- type ConfigurationList
- type Context
- type ContextProvider
- type Evaluator
- type GenericConfig
- type Updater
Constants ¶
const AllGenerations int64 = 0
const CONTEXT_TYPE = "config" + datacontext.OCM_CONTEXT_SUFFIX
const KIND_CONFIGSET = "config set"
const KIND_CONFIGTYPE = "config type"
const OCM_CONFIG_SUFFIX = ".config.ocm.software"
OCM_CONFIG_SUFFIX is the standard suffix used for all configuration types provided by this library.
const OCM_CONFIG_TYPE_SUFFIX = ".config" + common.OCM_TYPE_GROUP_SUFFIX
OCM_CONFIG_TYPE_SUFFIX is the standard suffix used for configuration types provided by this library.
Variables ¶
var AllAppliedConfigs = AppliedConfigSelectorFunction(func(*AppliedConfig) bool { return true })
var AllConfigs = AppliedConfigSelectorFunction(func(*AppliedConfig) bool { return true })
var DefaultConfigTypeScheme = NewConfigTypeScheme(nil)
DefaultConfigTypeScheme contains all globally known access serializer.
var DefaultContext = Builder{}.New(datacontext.MODE_SHARED)
DefaultContext is the default context initialized by init functions.
var Logger = ocmlog.DynamicLogger(Realm)
var Realm = ocmlog.DefineSubRealm("configuration management", "config")
Functions ¶
func ErrNoContext ¶
func IsErrNoContext ¶
func NewStrictConfigTypeScheme ¶ added in v0.3.0
func NewStrictConfigTypeScheme(base ...ConfigTypeScheme) runtime.VersionedTypeRegistry[Config, ConfigType]
Types ¶
type AppliedConfig ¶
type AppliedConfig struct {
// contains filtered or unexported fields
}
type AppliedConfigSelector ¶
type AppliedConfigSelector interface {
Select(cfg *AppliedConfig) bool
}
func AppliedAndSelector ¶
func AppliedAndSelector(and ...AppliedConfigSelector) AppliedConfigSelector
func AppliedConfigSelectorFor ¶
func AppliedConfigSelectorFor(s ConfigSelector) AppliedConfigSelector
func AppliedGenerationSelector ¶
func AppliedGenerationSelector(gen int64) AppliedConfigSelector
func AppliedVersionSelector ¶
func AppliedVersionSelector(v string) AppliedConfigSelector
type AppliedConfigSelectorFunction ¶
type AppliedConfigSelectorFunction func(cfg *AppliedConfig) bool
func (AppliedConfigSelectorFunction) Select ¶
func (f AppliedConfigSelectorFunction) Select(cfg *AppliedConfig) bool
type AppliedConfigs ¶
type AppliedConfigs []*AppliedConfig
func (AppliedConfigs) Configs ¶
func (l AppliedConfigs) Configs() []Config
func (AppliedConfigs) Len ¶
func (l AppliedConfigs) Len() int
func (AppliedConfigs) Less ¶
func (l AppliedConfigs) Less(i, j int) bool
func (AppliedConfigs) Swap ¶
func (l AppliedConfigs) Swap(i, j int)
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
func (Builder) New ¶
func (b Builder) New(m ...datacontext.BuilderMode) Context
func (Builder) WithConfigTypeScheme ¶
func (b Builder) WithConfigTypeScheme(scheme ConfigTypeScheme) Builder
func (Builder) WithSharedAttributes ¶
func (b Builder) WithSharedAttributes(ctx datacontext.AttributesContext) Builder
type Config ¶
type Config interface { runtime.VersionedTypedObject ApplyTo(Context, interface{}) error }
func NewGenericConfig ¶
func NewGenericConfig(data []byte, unmarshaler runtime.Unmarshaler) (Config, error)
type ConfigApplier ¶ added in v0.7.0
type ConfigApplier interface {
ApplyConfigTo(Context, cfg, tgt interface{}) error
}
type ConfigApplierFunction ¶ added in v0.7.0
func (ConfigApplierFunction) ApplyConfigTo ¶ added in v0.7.0
func (f ConfigApplierFunction) ApplyConfigTo(ctx Context, cfg, tgt interface{}) error
type ConfigDecoder ¶ added in v0.3.0
type ConfigDecoder = runtime.TypedObjectDecoder[Config]
type ConfigSelector ¶
type ConfigSelectorFunction ¶
func (ConfigSelectorFunction) Select ¶
func (f ConfigSelectorFunction) Select(cfg Config) bool
type ConfigSet ¶ added in v0.3.0
type ConfigSet struct { Description string `json:"description,omitempty"` ConfigurationList `json:",inline"` }
type ConfigStore ¶
type ConfigStore struct {
// contains filtered or unexported fields
}
func NewConfigStore ¶
func NewConfigStore() *ConfigStore
func (*ConfigStore) AddSet ¶ added in v0.3.0
func (c *ConfigStore) AddSet(name string, set *ConfigSet)
func (*ConfigStore) Apply ¶
func (s *ConfigStore) Apply(c Config, desc string)
func (*ConfigStore) Generation ¶
func (s *ConfigStore) Generation() int64
func (*ConfigStore) GetConfigForName ¶
func (c *ConfigStore) GetConfigForName(ctx Context, name string, selector AppliedConfigSelector) (int64, AppliedConfigs)
func (*ConfigStore) GetConfigForSelector ¶
func (c *ConfigStore) GetConfigForSelector(ctx Context, selector AppliedConfigSelector) (int64, AppliedConfigs)
func (*ConfigStore) GetConfigForType ¶
func (c *ConfigStore) GetConfigForType(ctx Context, typ string, selector AppliedConfigSelector) (int64, AppliedConfigs)
func (*ConfigStore) GetSet ¶ added in v0.3.0
func (c *ConfigStore) GetSet(name string) *ConfigSet
func (*ConfigStore) Reset ¶
func (s *ConfigStore) Reset() int64
type ConfigType ¶
type ConfigType interface { runtime.VersionedTypedObjectType[Config] Usage() string }
type ConfigTypeProvider ¶ added in v0.3.0
type ConfigTypeProvider = runtime.KnownTypesProvider[Config, ConfigType]
type ConfigTypeScheme ¶
type ConfigTypeScheme interface { runtime.TypeScheme[Config, ConfigType] Usage() string }
func NewConfigTypeScheme ¶
func NewConfigTypeScheme(defaultDecoder ConfigDecoder, base ...ConfigTypeScheme) ConfigTypeScheme
type ConfigurationList ¶ added in v0.3.0
type ConfigurationList struct {
Configurations []*GenericConfig `json:"configurations,omitempty"`
}
func (*ConfigurationList) AddConfig ¶ added in v0.3.0
func (c *ConfigurationList) AddConfig(cfg Config) error
func (*ConfigurationList) AddConfigData ¶ added in v0.5.0
func (c *ConfigurationList) AddConfigData(ctx Context, data []byte) error
type Context ¶
type Context interface { datacontext.Context ContextProvider AttributesContext() datacontext.AttributesContext // Info provides the context for nested configuration evaluation Info() string // WithInfo provides the same context with additional nesting info WithInfo(desc string) Context ConfigTypes() ConfigTypeScheme // GetConfigForData deserialize configuration objects for known // configuration types. GetConfigForData(data []byte, unmarshaler runtime.Unmarshaler) (Config, error) // ApplyData applies the config given by a byte stream to the config store // If the config type is not known, a generic config is stored and returned. // In this case an unknown error for kind KIND_CONFIGTYPE is returned. ApplyData(data []byte, unmarshaler runtime.Unmarshaler, desc string) (Config, error) // ApplyConfig applies the config to the config store ApplyConfig(spec Config, desc string) error GetConfigForType(generation int64, typ string) (int64, []Config) GetConfigForName(generation int64, name string) (int64, []Config) GetConfig(generation int64, selector ConfigSelector) (int64, []Config) AddConfigSet(name string, set *ConfigSet) ApplyConfigSet(name string) error // Reset all configs applied so far, subsequent calls to ApplyTo will // ony see configs allpied after the last reset. Reset() int64 // Generation return the actual config generation. // this is a strictly increasing number, regardless of the number // of Reset calls. Generation() int64 // ApplyTo applies all configurations applied after the last reset with // a generation larger than the given watermark to the specified target. // A target may be any object. The applied configuration objects decide // on their own whether they are applicable for the given target. // The generation of the last applied object is returned to be used as // new watermark. ApplyTo(gen int64, target interface{}) (int64, error) }
func FromContext ¶ added in v0.3.0
FromContext returns the Context to use for context.Context. This is either an explicit context or the default context. The returned context incorporates the given context.
func FromProvider ¶ added in v0.3.0
func FromProvider(p ContextProvider) Context
type ContextProvider ¶
type ContextProvider interface {
ConfigContext() Context
}
type GenericConfig ¶
type GenericConfig struct { runtime.UnstructuredVersionedTypedObject `json:",inline"` // contains filtered or unexported fields }
func ToGenericConfig ¶
func ToGenericConfig(c Config) (*GenericConfig, error)
func (*GenericConfig) ApplyTo ¶
func (s *GenericConfig) ApplyTo(ctx Context, target interface{}) error
func (*GenericConfig) IsUnknown ¶ added in v0.3.0
func (s *GenericConfig) IsUnknown() bool
type Updater ¶
type Updater interface { // Update replays missing configuration requests // applicable for a dedicated type of context or configuration target // stored in a configuration context. // It should be created for and called from within such a context Update() error State() (int64, bool) GetContext() Context Lock() Unlock() RLock() RUnlock() }
Updater implements the generation based update protocol to update data contexts based on the config requests made to a configuration context.
func NewUpdater ¶
NewUpdater create a configuration updater for a configuration target based on a dedicated configuration context.