Documentation
¶
Index ¶
- Constants
- Variables
- func ErrNoContext(name string) error
- func IsErrConfigNotApplicable(err error) bool
- func IsErrNoContext(err error) bool
- func IsGeneric(cfg Config) bool
- 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 ConfigSelector
- type ConfigSelectorFunction
- type ConfigStore
- 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 (s *ConfigStore) Reset() int64
- type ConfigType
- type ConfigTypeScheme
- 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_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.
Functions ¶
func ErrNoContext ¶
func IsErrNoContext ¶
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 ConfigSelector ¶
type ConfigSelectorFunction ¶
func (ConfigSelectorFunction) Select ¶
func (f ConfigSelectorFunction) Select(cfg Config) bool
type ConfigStore ¶
type ConfigStore struct {
// contains filtered or unexported fields
}
func NewConfigStore ¶
func NewConfigStore() *ConfigStore
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) Reset ¶
func (s *ConfigStore) Reset() int64
type ConfigType ¶
type ConfigType interface {
runtime.TypedObjectDecoder
runtime.VersionedTypedObject
Usage() string
}
type ConfigTypeScheme ¶
type ConfigTypeScheme interface {
runtime.Scheme
AddKnownTypes(s ConfigTypeScheme)
GetConfigType(name string) ConfigType
Register(name string, atype ConfigType)
DecodeConfig(data []byte, unmarshaler runtime.Unmarshaler) (Config, error)
CreateConfig(obj runtime.TypedObject) (Config, error)
Usage() string
}
func NewConfigTypeScheme ¶
func NewConfigTypeScheme(defaultRepoDecoder runtime.TypedObjectDecoder, base ...ConfigTypeScheme) ConfigTypeScheme
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)
// 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 ForContext ¶
ForContext 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.
type ContextProvider ¶
type ContextProvider interface {
ConfigContext() Context
}
type GenericConfig ¶
type GenericConfig struct {
runtime.UnstructuredVersionedTypedObject `json:",inline"`
}
func ToGenericConfig ¶
func ToGenericConfig(c Config) (*GenericConfig, error)
func (*GenericConfig) ApplyTo ¶
func (s *GenericConfig) ApplyTo(ctx Context, target interface{}) error
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
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.