Documentation ¶
Index ¶
- Constants
- Variables
- type BoolRule
- func (b *BoolRule) Default() ctypes.ConfigValue
- func (b *BoolRule) GobDecode(buf []byte) error
- func (b *BoolRule) GobEncode() ([]byte, error)
- func (b *BoolRule) Key() string
- func (b *BoolRule) MarshalJSON() ([]byte, error)
- func (b *BoolRule) Maximum() ctypes.ConfigValue
- func (b *BoolRule) Minimum() ctypes.ConfigValue
- func (b *BoolRule) Required() bool
- func (b *BoolRule) Type() string
- func (b *BoolRule) Validate(cv ctypes.ConfigValue) error
- type ConfigPolicy
- func (c *ConfigPolicy) Add(ns []string, cpn *ConfigPolicyNode)
- func (c *ConfigPolicy) Freeze()
- func (c *ConfigPolicy) Get(ns []string) *ConfigPolicyNode
- func (c *ConfigPolicy) GetAll() map[string]*ConfigPolicyNode
- func (c *ConfigPolicy) GobDecode(buf []byte) error
- func (c *ConfigPolicy) GobEncode() ([]byte, error)
- func (c *ConfigPolicy) MarshalJSON() ([]byte, error)
- func (c *ConfigPolicy) UnmarshalJSON(data []byte) error
- type ConfigPolicyNode
- func (p *ConfigPolicyNode) Add(rules ...Rule)
- func (c *ConfigPolicyNode) AddDefaults(m map[string]ctypes.ConfigValue) (*map[string]ctypes.ConfigValue, *ProcessingErrors)
- func (c *ConfigPolicyNode) GobDecode(buf []byte) error
- func (c *ConfigPolicyNode) GobEncode() ([]byte, error)
- func (c *ConfigPolicyNode) HasRules() bool
- func (c *ConfigPolicyNode) MarshalJSON() ([]byte, error)
- func (c ConfigPolicyNode) Merge(n ctree.Node) ctree.Node
- func (c *ConfigPolicyNode) Process(m map[string]ctypes.ConfigValue) (*map[string]ctypes.ConfigValue, *ProcessingErrors)
- func (p *ConfigPolicyNode) RulesAsTable() []RuleTable
- func (c *ConfigPolicyNode) UnmarshalJSON(data []byte) error
- type FloatRule
- func (f *FloatRule) Default() ctypes.ConfigValue
- func (f *FloatRule) GobDecode(buf []byte) error
- func (f *FloatRule) GobEncode() ([]byte, error)
- func (f *FloatRule) Key() string
- func (f *FloatRule) MarshalJSON() ([]byte, error)
- func (i *FloatRule) Maximum() ctypes.ConfigValue
- func (i *FloatRule) Minimum() ctypes.ConfigValue
- func (f *FloatRule) Required() bool
- func (f *FloatRule) SetMaximum(m float64)
- func (f *FloatRule) SetMinimum(m float64)
- func (s *FloatRule) Type() string
- func (f *FloatRule) Validate(cv ctypes.ConfigValue) error
- type IntRule
- func (i *IntRule) Default() ctypes.ConfigValue
- func (i *IntRule) GobDecode(buf []byte) error
- func (i *IntRule) GobEncode() ([]byte, error)
- func (i *IntRule) Key() string
- func (i *IntRule) MarshalJSON() ([]byte, error)
- func (i *IntRule) Maximum() ctypes.ConfigValue
- func (i *IntRule) Minimum() ctypes.ConfigValue
- func (i *IntRule) Required() bool
- func (i *IntRule) SetMaximum(m int)
- func (i *IntRule) SetMinimum(m int)
- func (i *IntRule) Type() string
- func (i *IntRule) Validate(cv ctypes.ConfigValue) error
- type ProcessingErrors
- type Rule
- type RuleTable
- type StringRule
- func (s *StringRule) Default() ctypes.ConfigValue
- func (s *StringRule) GobDecode(buf []byte) error
- func (s *StringRule) GobEncode() ([]byte, error)
- func (s *StringRule) Key() string
- func (s *StringRule) MarshalJSON() ([]byte, error)
- func (s *StringRule) Maximum() ctypes.ConfigValue
- func (s *StringRule) Minimum() ctypes.ConfigValue
- func (s *StringRule) Required() bool
- func (s *StringRule) Type() string
- func (s *StringRule) Validate(cv ctypes.ConfigValue) error
Constants ¶
const (
BoolType = "bool"
)
const (
FloatType = "float"
)
const (
IntegerType = "integer"
)
const (
StringType = "string"
)
Variables ¶
var (
EmptyKeyError = errors.New("key cannot be empty")
)
Functions ¶
This section is empty.
Types ¶
type BoolRule ¶
type BoolRule struct {
// contains filtered or unexported fields
}
BoolRule validating against string-typed config
func NewBoolRule ¶
NewBoolRule Returns a new bool-typed rule. Arguments are key(string), required(bool), default(bool).
func (*BoolRule) Default ¶
func (b *BoolRule) Default() ctypes.ConfigValue
Default returns a default value is it exists.
func (*BoolRule) MarshalJSON ¶
MarshalJSON marshals a BoolRule into JSON
func (*BoolRule) Maximum ¶
func (b *BoolRule) Maximum() ctypes.ConfigValue
Maximum returns Maximum possible value of BoolRule
func (*BoolRule) Minimum ¶
func (b *BoolRule) Minimum() ctypes.ConfigValue
Minimum returns Minimum possible value of BoolRule
type ConfigPolicy ¶
type ConfigPolicy struct {
// contains filtered or unexported fields
}
Allows adding of config policy by namespace and retrieving of policy from a tree at a specific namespace (merging the relevant hiearchy). Uses pkg.ConfigTree.
func (*ConfigPolicy) Add ¶
func (c *ConfigPolicy) Add(ns []string, cpn *ConfigPolicyNode)
Adds a ConfigPolicyNode at the provided namespace.
func (*ConfigPolicy) Freeze ¶
func (c *ConfigPolicy) Freeze()
Freezes the ConfigPolicy from future writes (adds) and triggers compression of tree into read-performant version.
func (*ConfigPolicy) Get ¶
func (c *ConfigPolicy) Get(ns []string) *ConfigPolicyNode
Returns a ConfigPolicyNode that is a merged version of the namespace provided.
func (*ConfigPolicy) GetAll ¶
func (c *ConfigPolicy) GetAll() map[string]*ConfigPolicyNode
func (*ConfigPolicy) GobDecode ¶
func (c *ConfigPolicy) GobDecode(buf []byte) error
func (*ConfigPolicy) GobEncode ¶
func (c *ConfigPolicy) GobEncode() ([]byte, error)
func (*ConfigPolicy) MarshalJSON ¶
func (c *ConfigPolicy) MarshalJSON() ([]byte, error)
MarshalJSON marshals a ConfigPolicy into JSON
func (*ConfigPolicy) UnmarshalJSON ¶
func (c *ConfigPolicy) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshals JSON into a ConfigPolicy
type ConfigPolicyNode ¶
type ConfigPolicyNode struct {
// contains filtered or unexported fields
}
func NewPolicyNode ¶
func NewPolicyNode() *ConfigPolicyNode
func (*ConfigPolicyNode) Add ¶
func (p *ConfigPolicyNode) Add(rules ...Rule)
Adds a rule to this policy node
func (*ConfigPolicyNode) AddDefaults ¶
func (c *ConfigPolicyNode) AddDefaults(m map[string]ctypes.ConfigValue) (*map[string]ctypes.ConfigValue, *ProcessingErrors)
AddDefaults validates and returns a processed policy node or nil and error if validation has failed
func (*ConfigPolicyNode) GobDecode ¶
func (c *ConfigPolicyNode) GobDecode(buf []byte) error
func (*ConfigPolicyNode) GobEncode ¶
func (c *ConfigPolicyNode) GobEncode() ([]byte, error)
func (*ConfigPolicyNode) HasRules ¶
func (c *ConfigPolicyNode) HasRules() bool
func (*ConfigPolicyNode) MarshalJSON ¶
func (c *ConfigPolicyNode) MarshalJSON() ([]byte, error)
func (ConfigPolicyNode) Merge ¶
func (c ConfigPolicyNode) Merge(n ctree.Node) ctree.Node
Merges a ConfigPolicyNode on top of this one (overwriting items where it occurs).
func (*ConfigPolicyNode) Process ¶
func (c *ConfigPolicyNode) Process(m map[string]ctypes.ConfigValue) (*map[string]ctypes.ConfigValue, *ProcessingErrors)
Validates and returns a processed policy node or nil and error if validation has failed
func (*ConfigPolicyNode) RulesAsTable ¶
func (p *ConfigPolicyNode) RulesAsTable() []RuleTable
func (*ConfigPolicyNode) UnmarshalJSON ¶
func (c *ConfigPolicyNode) UnmarshalJSON(data []byte) error
UnmarshalJSON unmarshals JSON into a ConfigPolicyNode
type FloatRule ¶
type FloatRule struct {
// contains filtered or unexported fields
}
FloatRule A rule validating against string-typed config
func NewFloatRule ¶
NewFloatRule Returns a new float-typed rule. Arguments are key(string), required(bool), default(float64), min(float64), max(float64)
func (*FloatRule) Default ¶
func (f *FloatRule) Default() ctypes.ConfigValue
Default returns the rule's default value
func (*FloatRule) MarshalJSON ¶
MarshalJSON marshals a FloatRule into JSON
func (*FloatRule) Maximum ¶
func (i *FloatRule) Maximum() ctypes.ConfigValue
func (*FloatRule) Minimum ¶
func (i *FloatRule) Minimum() ctypes.ConfigValue
func (*FloatRule) SetMaximum ¶
SetMaximum sets the maximum allowable value for this rule
func (*FloatRule) SetMinimum ¶
SetMinimum sets the minimum allowable value for this rule
type IntRule ¶
type IntRule struct {
// contains filtered or unexported fields
}
A rule validating against string-typed config
func NewIntegerRule ¶
Returns a new int-typed rule. Arguments are key(string), required(bool), default(int), min(int), max(int)
func (*IntRule) Default ¶
func (i *IntRule) Default() ctypes.ConfigValue
Default return this rules default value
func (*IntRule) MarshalJSON ¶
MarshalJSON marshals a IntRule into JSON
func (*IntRule) Maximum ¶
func (i *IntRule) Maximum() ctypes.ConfigValue
func (*IntRule) Minimum ¶
func (i *IntRule) Minimum() ctypes.ConfigValue
func (*IntRule) SetMaximum ¶
SetMaximum sets the maximum allowed value
func (*IntRule) SetMinimum ¶
SetMinimum sets the minimum allowed value
type ProcessingErrors ¶
type ProcessingErrors struct {
// contains filtered or unexported fields
}
func NewProcessingErrors ¶
func NewProcessingErrors() *ProcessingErrors
func (*ProcessingErrors) AddError ¶
func (p *ProcessingErrors) AddError(e error)
func (*ProcessingErrors) Errors ¶
func (p *ProcessingErrors) Errors() []error
func (*ProcessingErrors) HasErrors ¶
func (p *ProcessingErrors) HasErrors() bool
type Rule ¶
type Rule interface { Key() string Validate(ctypes.ConfigValue) error Default() ctypes.ConfigValue Required() bool Type() string Minimum() ctypes.ConfigValue Maximum() ctypes.ConfigValue }
A rule used to process ConfigData
type StringRule ¶
type StringRule struct {
// contains filtered or unexported fields
}
A rule validating against string-typed config
func NewStringRule ¶
func NewStringRule(key string, req bool, opts ...string) (*StringRule, error)
Returns a new string-typed rule. Arguments are key(string), required(bool), default(string).
func (*StringRule) Default ¶
func (s *StringRule) Default() ctypes.ConfigValue
Returns a default value is it exists.
func (*StringRule) GobDecode ¶
func (s *StringRule) GobDecode(buf []byte) error
GobDecode decodes a GOB into a StringRule
func (*StringRule) GobEncode ¶
func (s *StringRule) GobEncode() ([]byte, error)
GobEncode encodes a StringRule in to a GOB
func (*StringRule) MarshalJSON ¶
func (s *StringRule) MarshalJSON() ([]byte, error)
MarshalJSON marshals a StringRule into JSON
func (*StringRule) Maximum ¶
func (s *StringRule) Maximum() ctypes.ConfigValue
func (*StringRule) Minimum ¶
func (s *StringRule) Minimum() ctypes.ConfigValue
func (*StringRule) Type ¶
func (s *StringRule) Type() string
func (*StringRule) Validate ¶
func (s *StringRule) Validate(cv ctypes.ConfigValue) error
Validates a config value against this rule.