option

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 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:"-"`
}

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) Disable

func (bo *BoolOptions) Disable(name string)

Disable disables the option `name`. All options which depend on the option to be disabled will be disabled. Options which have previously been enabled as a dependency will not be automatically disabled.

func (*BoolOptions) Dump

func (bo *BoolOptions) Dump()

func (*BoolOptions) Enable

func (bo *BoolOptions) Enable(name string)

Enable enables the option `name` with all its dependencies

func (*BoolOptions) GetFmtList

func (bo *BoolOptions) GetFmtList() string

func (*BoolOptions) GetFmtOpt

func (bo *BoolOptions) GetFmtOpt(name string) string

GetFmtOpt returns #define name if option exists and is set to true in endpoint's Opts map or #undef name if option does not exist or exists but is set to false

func (*BoolOptions) GetModel

func (bo *BoolOptions) GetModel() *models.Configuration

func (*BoolOptions) InheritDefault

func (bo *BoolOptions) InheritDefault(parent *BoolOptions, key string)

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 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 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