Documentation ¶
Index ¶
- func NormalizeBool(value string) (bool, error)
- func ParseOption(arg string, lib *OptionLibrary) (string, bool, error)
- type BoolOptions
- func (bo *BoolOptions) Apply(n models.ConfigurationMap, changed ChangedFunc, data interface{}) int
- func (bo *BoolOptions) DeepCopy() *BoolOptions
- func (bo *BoolOptions) Delete(key string)
- func (bo *BoolOptions) Dump()
- func (bo *BoolOptions) GetFmtList() string
- func (bo *BoolOptions) GetModel() *models.Configuration
- func (bo *BoolOptions) InheritDefault(parent *BoolOptions, key string)
- func (bo *BoolOptions) IsDisabled(key string) bool
- func (bo *BoolOptions) IsEnabled(key string) bool
- func (bo *BoolOptions) Set(key string, value bool)
- func (bo *BoolOptions) SetIfUnset(key string, value bool)
- func (bo *BoolOptions) Validate(n models.ConfigurationMap) error
- type ChangedFunc
- type MapOptions
- type NamedMapOptions
- type Option
- type OptionLibrary
- type OptionMap
- type Validator
- type VerifyFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NormalizeBool ¶
func ParseOption ¶
func ParseOption(arg string, lib *OptionLibrary) (string, bool, error)
Types ¶
type BoolOptions ¶
type BoolOptions struct { Opts OptionMap `json:"map"` Library *OptionLibrary `json:"-"` // contains filtered or unexported fields }
func NewBoolOptions ¶
func NewBoolOptions(lib *OptionLibrary) *BoolOptions
func (*BoolOptions) Apply ¶
func (bo *BoolOptions) Apply(n models.ConfigurationMap, changed ChangedFunc, data interface{}) int
Apply takes a configuration map and applies the changes. For an option which is changed, the `ChangedFunc` function is called with the `data` argument passed in as well. Returns the number of options changed if any.
func (*BoolOptions) DeepCopy ¶
func (bo *BoolOptions) DeepCopy() *BoolOptions
func (*BoolOptions) Delete ¶
func (bo *BoolOptions) Delete(key string)
func (*BoolOptions) Dump ¶
func (bo *BoolOptions) Dump()
func (*BoolOptions) GetFmtList ¶
func (bo *BoolOptions) GetFmtList() string
func (*BoolOptions) GetModel ¶
func (bo *BoolOptions) GetModel() *models.Configuration
func (*BoolOptions) InheritDefault ¶
func (bo *BoolOptions) InheritDefault(parent *BoolOptions, key string)
func (*BoolOptions) IsDisabled ¶ added in v0.9.0
func (bo *BoolOptions) IsDisabled(key string) bool
func (*BoolOptions) IsEnabled ¶
func (bo *BoolOptions) IsEnabled(key string) bool
func (*BoolOptions) Set ¶
func (bo *BoolOptions) Set(key string, value bool)
func (*BoolOptions) SetIfUnset ¶
func (bo *BoolOptions) SetIfUnset(key string, value bool)
func (*BoolOptions) Validate ¶
func (bo *BoolOptions) Validate(n models.ConfigurationMap) error
Validate validates a given configuration map based on the option library
type ChangedFunc ¶
ChangedFunc is called by `Apply()` for each option changed
type MapOptions ¶ added in v0.10.0
type MapOptions struct {
// contains filtered or unexported fields
}
MapOptions holds a map of values and a validation function.
func NewMapOpts ¶ added in v0.10.0
func NewMapOpts(values map[string]string, validator Validator) *MapOptions
NewMapOpts creates a new MapOpts with the specified map of values and an optional validator.
func (*MapOptions) Set ¶ added in v0.10.0
func (opts *MapOptions) Set(value string) error
Set validates, if needed, the input value and adds it to the internal map, by splitting on '='.
func (*MapOptions) String ¶ added in v0.10.0
func (opts *MapOptions) String() string
func (*MapOptions) Type ¶ added in v0.10.0
func (opts *MapOptions) Type() string
Type returns a string name for this Option type
type NamedMapOptions ¶ added in v0.10.0
type NamedMapOptions struct { MapOptions // contains filtered or unexported fields }
NamedMapOptions is a MapOptions struct with a configuration name. This struct is useful to keep reference to the assigned field name in the internal configuration struct.
func NewNamedMapOptions ¶ added in v0.10.0
func NewNamedMapOptions(name string, values *map[string]string, validator Validator) *NamedMapOptions
NewNamedMapOptions creates a reference to a new NamedMapOpts struct.
type Option ¶
type Option struct { // Define is the name of the #define used for BPF programs Define string // Description is a short human readable description Description string // Immutable marks an option which is read-only Immutable bool // Requires is a list of required options, such options will be // automatically enabled as required. Requires []string // Verify is called prior to applying the option Verify VerifyFunc }
Option is the structure used to specify the semantics of a configurable boolean option
func (Option) RequiresOption ¶
RequiresOption returns true if the option requires the specified option `name`.
type OptionLibrary ¶
func (OptionLibrary) Define ¶
func (l OptionLibrary) Define(name string) string
type VerifyFunc ¶
VerifyFunc validates option key with value and may return an error if the option should not be applied