option

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2017 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NormalizeBool

func NormalizeBool(value string) (bool, error)

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

type ChangedFunc func(key string, value bool, data interface{})

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

func (o Option) RequiresOption(name string) bool

RequiresOption returns true if the option requires the specified option `name`.

type OptionLibrary

type OptionLibrary map[string]*Option

func (OptionLibrary) Define

func (l OptionLibrary) Define(name string) string

func (OptionLibrary) Lookup

func (l OptionLibrary) Lookup(name string) (string, *Option)

func (OptionLibrary) Validate

func (l OptionLibrary) Validate(name string, value bool) error

type OptionMap

type OptionMap map[string]bool

func (OptionMap) DeepCopy

func (om OptionMap) DeepCopy() OptionMap

type Validator added in v0.10.0

type Validator func(val string) (string, error)

Validator returns a validated string along with a possible error.

type VerifyFunc

type VerifyFunc func(key string, value bool) error

VerifyFunc validates option key with value and may return an error if the option should not be applied

Jump to

Keyboard shortcuts

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