schema

package
v0.0.0-...-17f8324 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2021 License: BSD-3-Clause, MPL-2.0 Imports: 19 Imported by: 8

Documentation

Index

Constants

View Source
const (
	Current = iota
	Deprecated
	Obsolete
)

Variables

This section is empty.

Functions

func AddDefaults

func AddDefaults(schema Node, under datanode.DataNode) datanode.DataNode

Create a wrapper around a datanode that provides defaults

func ConvertToXpathNode

func ConvertToXpathNode(c datanode.DataNode, s Node) xutils.XpathNode

func FilterTree

func FilterTree(schema Node, under datanode.DataNode, keep_it Filter) datanode.DataNode

Create a wrapper around a datanode that filters out unwanted nodes

func IsActiveDefault

func IsActiveDefault(sch Node, name string, cfgChkr ConfigChecker) bool

IsActiveDefault - Check default nodes and determine if they are active defaults that should be instantiated.

A node is an active default in one of the given circumstances

  • The node is under a choice but there is no active configuration under the choice, any nodes under the default case, if it is defined, become active defaults.
  • There is config under one of the cases in a choice, any other node in that case will be an active default.
  • The node is not under a choice and has a default

isActiveDefault() and isActiveDefaultCase() are called recursively to traverse down a choice/case

func NewEmptyLeafValueError

func NewEmptyLeafValueError(name string, path []string) error

func NewInvalidPathError

func NewInvalidPathError(path []string) error

func NewMissingChildError

func NewMissingChildError(path []string) error

func NewMissingKeyError

func NewMissingKeyError(path []string) error

func NewMissingValueError

func NewMissingValueError(path []string) error

func NewNode

func NewNode() *node

func NewNodeExistsError

func NewNodeExistsError(path []string) error

func NewNodeNotExistsError

func NewNodeNotExistsError(path []string) error

func NewPathInvalidError

func NewPathInvalidError(path []string, invalidElem string) error

Preferred to NewInvalidPathError, generating consistent error type and consistent path style (split between path and info fields). Legacy one kept to avoid having to play with opd errors.

func NewSchemaMismatchError

func NewSchemaMismatchError(name string, path []string) error

func ValidateSchema

func ValidateSchema(
	sn Node, c datanode.DataNode, debug bool,
) ([]*exec.Output, []error, bool)

func ValidateSchemaWithLog

func ValidateSchemaWithLog(
	sn Node, c datanode.DataNode, options ...YangDebugOption,
) ([]*exec.Output, []error, bool)

Types

type ActionFnType

type ActionFnType func(
	targetNode Node,
	parentNode *XNode,
	nodeToFind NodeSpec,
	path []string,
	param interface{},
) (done, success bool, retSlice []interface{})

ActionFnType - action to be carried out on each node during a walk. As the tree is walked, we carry out the actionFn on each node in turn. For a find operation, this function may return <done> as true, indicating no further walking is required. At this point, <success> indicates whether the overall 'mission' of the walk was successful or not. Otherwise, if a walk runs to completion (all nodes walked) we return true. <retSlice> is used to store any number of objects returned by each invocation of the actionFn, eg output(s) generated by each node.

type Binary

type Binary interface {
	Type
	Length() *Length
	// contains filtered or unexported methods
}

func NewBinary

func NewBinary() Binary

type Bit

type Bit struct {
	Name string
	Desc string
	Ref  string

	Pos int32
	// contains filtered or unexported fields
}

func NewBit

func NewBit(name, desc, ref string, status Status, pos int32) *Bit

func (*Bit) Status

func (b *Bit) Status() Status

func (*Bit) String

func (b *Bit) String() string

type BitWidth

type BitWidth int
const (
	BitWidth8  BitWidth = 8
	BitWidth16 BitWidth = 16
	BitWidth32 BitWidth = 32
	BitWidth64 BitWidth = 64
)

type Bits

type Bits interface {
	Type
	Bits() []*Bit
	// contains filtered or unexported methods
}

func NewBits

func NewBits(bs []*Bit) Bits

type Boolean

type Boolean interface {
	Type
	// contains filtered or unexported methods
}

func NewBoolean

func NewBoolean(
	name xml.Name,
	def string,
	hasDef bool,
) Boolean

type Case

type Case interface {
	Node
	// contains filtered or unexported methods
}

func NewCase

func NewCase(
	name, namespace, modulename, submodule, desc, ref string,
	config bool,
	status Status,
	whens []WhenContext,
	children []Node,
) (Case, error)

type Choice

type Choice interface {
	Node
	DefaultCase() string
	// contains filtered or unexported methods
}

func NewChoice

func NewChoice(
	name, namespace, modulename, submodulename, def, desc, ref string,
	mandatory, config bool,
	status Status,
	whens []WhenContext,
	children []Node,
) (Choice, error)

type ConfigChecker

type ConfigChecker func(sch Node) bool

type Container

type Container interface {
	Node
	Presence() bool
	// contains filtered or unexported methods
}

func NewContainer

func NewContainer(
	name, namespace, modulename, submodule, desc, ref string,
	presence, config bool,
	status Status,
	whens []WhenContext,
	musts []MustContext,
	children []Node,
) (Container, error)

type Decimal64

type Decimal64 interface {
	Number
	Fd() Fracdigit
	Rbs() DrbSlice
	// contains filtered or unexported methods
}

func NewDecimal64

func NewDecimal64(
	name xml.Name,
	fd Fracdigit,
	rbs []Drb,
	msg string,
	appTag string,
	def string,
	hasDef bool,
) Decimal64

type Drb

type Drb struct {
	Start, End float64
}

decimal64 range boundary (Drb)

func NewDecimalRangeBoundary

func NewDecimalRangeBoundary(start, end float64) Drb

func (Drb) Error

func (r Drb) Error() string

func (Drb) String

func (r Drb) String() string

func (Drb) Validate

func (r Drb) Validate(i float64) error

type DrbSlice

type DrbSlice []Drb

To allow us to provide common handling for different RangeBoundary types it is useful to create an explicit slice type for each RB type as we can then create functions that operate on such slices. We use these functions from the common handling functions using the magic of interface{}.

func (DrbSlice) Append

func (rangeBdry DrbSlice) Append(start, end interface{}) RangeBoundarySlicer

func (DrbSlice) Contiguous

func (rangeBdry DrbSlice) Contiguous(lower, higher interface{}) bool

func (DrbSlice) Create

func (rangeBdry DrbSlice) Create(entries, capacity int) RangeBoundarySlicer

func (DrbSlice) GetEnd

func (rangeBdry DrbSlice) GetEnd(i int) interface{}

func (DrbSlice) GetStart

func (rangeBdry DrbSlice) GetStart(i int) interface{}

func (DrbSlice) GreaterThan

func (rangeBdry DrbSlice) GreaterThan(first, second interface{}) bool

func (DrbSlice) Len

func (rangeBdry DrbSlice) Len() int

func (DrbSlice) LessThan

func (rangeBdry DrbSlice) LessThan(first, second interface{}) bool

func (DrbSlice) Parse

func (rangeBdry DrbSlice) Parse(start string, base int, bitSize int) (interface{}, error)

func (DrbSlice) String

func (rangeBdry DrbSlice) String(i int) string

type Empty

type Empty interface {
	Type
	// contains filtered or unexported methods
}

func NewEmpty

func NewEmpty(name xml.Name, def string, hasDef bool) Empty

type Enum

type Enum struct {
	Val  string
	Desc string
	Ref  string

	Value int
	// contains filtered or unexported fields
}

func NewEnum

func NewEnum(val, desc, ref string, status Status, value int) *Enum

func (*Enum) Status

func (e *Enum) Status() Status

func (*Enum) String

func (e *Enum) String() string

type Enumeration

type Enumeration interface {
	Type
	Enums() []*Enum
	String() string
	// contains filtered or unexported methods
}

func NewEnumeration

func NewEnumeration(
	name xml.Name,
	enums []*Enum,
	def string,
	hasDef bool,
) Enumeration

type Filter

type Filter func(Node, datanode.DataNode, []datanode.DataNode) bool

type Fracdigit

type Fracdigit int

type Identity

type Identity struct {
	Val  string
	Desc string
	Ref  string

	Value     string
	Module    string
	Namespace string
	// contains filtered or unexported fields
}

func NewIdentity

func NewIdentity(mod, namespace, val, desc, ref string, status Status, value string) *Identity

func (*Identity) Status

func (i *Identity) Status() Status

func (*Identity) String

func (i *Identity) String() string

type Identityref

type Identityref interface {
	Type
	Identities() []*Identity
	String() string
	// contains filtered or unexported methods
}

func NewIdentityref

func NewIdentityref(
	name xml.Name,
	ids []*Identity,
	def string,
	hasDef bool,
) Identityref

type InstanceId

type InstanceId interface {
	Type
	Require() bool
	// contains filtered or unexported methods
}

func NewInstanceId

func NewInstanceId(
	name xml.Name,
	require bool,
	def string,
	hasDef bool,
) InstanceId

type Integer

type Integer interface {
	Number
	Rbs() RbSlice
	// contains filtered or unexported methods
}

func NewInteger

func NewInteger(
	bitSize BitWidth,
	name xml.Name,
	rbs []Rb,
	msg string,
	appTag string,
	def string,
	hasDef bool,
) Integer

type Lb

type Lb struct {
	Start, End uint64
	// contains filtered or unexported fields
}

string length (range) boundary (Lb)

func NewLengthBoundary

func NewLengthBoundary(start, end uint64) Lb

func (*Lb) Error

func (l *Lb) Error() string

func (*Lb) String

func (l *Lb) String() string

func (*Lb) Validate

func (l *Lb) Validate(i uint64) error

type LbSlice

type LbSlice []Lb

Lb RangeBoundarySlicer interface implementation

func (LbSlice) Append

func (rangeBdry LbSlice) Append(start, end interface{}) RangeBoundarySlicer

func (LbSlice) Contiguous

func (rangeBdry LbSlice) Contiguous(lower, higher interface{}) bool

func (LbSlice) Create

func (rangeBdry LbSlice) Create(entries, capacity int) RangeBoundarySlicer

func (LbSlice) GetEnd

func (rangeBdry LbSlice) GetEnd(i int) interface{}

func (LbSlice) GetStart

func (rangeBdry LbSlice) GetStart(i int) interface{}

func (LbSlice) GreaterThan

func (rangeBdry LbSlice) GreaterThan(first, second interface{}) bool

func (LbSlice) Len

func (rangeBdry LbSlice) Len() int

func (LbSlice) LessThan

func (rangeBdry LbSlice) LessThan(first, second interface{}) bool

func (LbSlice) Parse

func (rangeBdry LbSlice) Parse(start string, base int, bitSize int) (interface{}, error)

func (LbSlice) String

func (rangeBdry LbSlice) String(i int) string

type Leaf

type Leaf interface {
	Node
	Default() (string, bool)
	// contains filtered or unexported methods
}

func NewLeaf

func NewLeaf(
	name, namespace, modulename, submodule, desc, ref, units string,
	mandatory bool,
	typ Type,
	config bool,
	status Status,
	whens []WhenContext,
	musts []MustContext,
) Leaf

type LeafList

type LeafList interface {
	Node
	Limit() Limit
	// contains filtered or unexported methods
}

func NewLeafList

func NewLeafList(
	name, namespace, modulename, submodule,
	desc, ref, def, orderedby, units string,
	min, max uint,
	typ Type,
	config bool,
	status Status,
	whens []WhenContext,
	musts []MustContext,
) LeafList

type LeafValue

type LeafValue interface {
	Node
	IsLeafValue()
}

type Leafref

type Leafref interface {
	Type
	Mach() *xpath.Machine
	GetAbsPath(xutils.PathType) xutils.PathType
	// contains filtered or unexported methods
}

func NewLeafref

func NewLeafref(
	name xml.Name,
	mach *xpath.Machine,
	def string,
	hasDef bool,
) Leafref

type Length

type Length struct {
	Lbs    LbSlice
	Msg    string
	AppTag string
	// contains filtered or unexported fields
}

Length

func (*Length) Validate

func (l *Length) Validate(i uint64) error

type Limit

type Limit struct {
	Min uint
	Max uint
}

type List

type List interface {
	Node
	Limit() Limit
	Keys() []string
	Uniques() [][][]xml.Name
	// contains filtered or unexported methods
}

func NewList

func NewList(
	name, namespace, modulename, submodule, desc, ref, orderedby string,
	min, max uint,
	config bool,
	status Status,
	keys []string,
	uniques [][][]xml.Name,
	whens []WhenContext,
	musts []MustContext,
	children []Node,
) (List, error)

type ListEntry

type ListEntry interface {
	Node
	Keys() []string
	// contains filtered or unexported methods
}

type Model

type Model interface {
	Tree
	EncodeXML(*xml.Encoder)
	Identifier() string
	Version() string
	Data() string
	Features() []string
	Rpcs() map[string]Rpc
	Notifications() map[string]Notification
	Deviations() []string
	// contains filtered or unexported methods
}

func NewModel

func NewModel(
	name, revision, namespace, data string,
	tree Tree,
	rpcs map[string]Rpc,
	features []string,
	notifications map[string]Notification,
	deviations []string,
) Model

type ModelSet

type ModelSet interface {
	Tree
	Modules() map[string]Model
	Submodules() map[string]Submodule
	Rpcs() map[string]map[string]Rpc
	Notifications() map[string]map[string]Notification

	FindOrWalk(
		nodeToFind NodeSpec,
		actionFn ActionFnType,
		param interface{}) (Node, bool, []interface{})
	// contains filtered or unexported methods
}

func NewModelSet

func NewModelSet(modules map[string]Model, submodules map[string]Submodule,
) (ModelSet, error)

type MustContext

type MustContext struct {
	WhenAndMustContext

	// Used to evaluate paths in the configd:must extension
	ExtPathEvalMach *xpath.Machine
}

func NewMustContext

func NewMustContext(
	mach, basePathEvalMach, extPathEvalMach *xpath.Machine,
	errMsg string,
	appTag string,
	namespace string,
) MustContext

type Node

type Node interface {
	Child(string) Node

	Descendant([]string) Node
	Validate(ValidateCtx, []string, []string) error
	CheckCardinality(xutils.PathType, int) error
	Children() []Node
	OpdChildren() []Node
	Choices() []Node
	Name() string
	Namespace() string
	Module() string
	Submodule() string
	Paths(string) []string
	Whens() []WhenContext
	Musts() []MustContext
	Type() Type
	HasDefault() bool
	DefaultChild(name string) Node
	DefaultChildNames() []string
	DefaultChildren() []Node
	OrdBy() string
	HasPresence() bool
	Config() bool
	String() string
	Status() Status
	Description() string
	Repeatable() bool

	Parent() *node

	Arguments() []string
	Mandatory() bool
	// contains filtered or unexported methods
}

type NodeProperty

type NodeProperty struct {
	NodeProp  string
	NodeValue string
}

Structures used to specify the properties of the node to be found during a walk.

type NodeSpec

type NodeSpec struct {
	Path                  []string
	DefaultPropNotPresent bool // If true, we expect node to exist w/o property
	Statement             NodeSubSpec
	DataPropNotPresent    bool // If true, we expect node to exist w/o data
	Data                  NodeSubSpec
}

For the likes of verifying default is NOT set on a node, we have the NotPresent options, which default to false (present) as that is the more commonly tested case and this avoids needing to specify these so often.

Note that NotPresent means node either doesn't exist, or has a different value to that specified.

type NodeSubSpec

type NodeSubSpec struct {
	Type       string
	Properties []NodeProperty
}

type Notification

type Notification interface {
	Schema() Tree
	// contains filtered or unexported methods
}

func NewNotification

func NewNotification(n Tree) Notification

type Number

type Number interface {
	Type
	Ranges() RangeBoundarySlicer
	Msg() string
	AppTag() string
	BitWidth() BitWidth
}

type OpdArgument

type OpdArgument interface {
	Node
	Default() (string, bool)
	OnEnter() string
	Privileged() bool
	Local() bool
	Secret() bool
	PassOpcArgs() bool
	// contains filtered or unexported methods
}

func NewOpdArgument

func NewOpdArgument(
	name, namespace, modulename, desc, ref, units, onenter string,
	priv bool,
	local bool,
	secret bool,
	repeatable bool,
	mandatory bool,
	passOpcArgs bool,
	typ Type,
	status Status,
	children []Node,
) (OpdArgument, error)

type OpdCommand

type OpdCommand interface {
	Node
	OnEnter() string
	Privileged() bool
	Local() bool
	Secret() bool
	PassOpcArgs() bool
	// contains filtered or unexported methods
}

func NewOpdCommand

func NewOpdCommand(
	name, namespace, modulename, desc, ref, onenter string,
	priv bool,
	local bool,
	secret bool,
	repeatable bool,
	passOpcArgs bool,
	status Status,
	children []Node,
) (OpdCommand, error)

type OpdOption

type OpdOption interface {
	Node
	Default() (string, bool)
	OnEnter() string
	Privileged() bool
	Local() bool
	Secret() bool
	PassOpcArgs() bool
	// contains filtered or unexported methods
}

func NewOpdOption

func NewOpdOption(
	name, namespace, modulename, desc, ref, units, onenter string,
	priv bool,
	local bool,
	secret bool,
	repeatable bool,
	mandatory bool,
	passOpcArgs bool,
	typ Type,
	status Status,
	children []Node,
) (OpdOption, error)

type OpdOptionValue

type OpdOptionValue interface {
	Node
	IsOpdOptionValue()
}

type Pattern

type Pattern struct {
	Pattern string
	*regexp.Regexp
	Msg    string
	AppTag string
}

func NewPattern

func NewPattern(re *regexp.Regexp) Pattern

func (Pattern) String

func (p Pattern) String() string

func (Pattern) Validate

func (p Pattern) Validate(s string) error

type RangeBoundarySlicer

type RangeBoundarySlicer interface {
	// Return length of RangeBoundary
	Len() int

	// Pretty-print function for %s
	String(i int) string

	// Return start/end value at given position in the slice
	GetStart(i int) interface{}
	GetEnd(i int) interface{}

	// For ranges with discrete values (ie int/uint/string), if one range
	// ends at 'x' and the following one starts at 'x + 1', then the two
	// ranges may be deemed to be contiguous, and a derived type or
	// refined range may span the two.
	//
	// NB: decimal64 covers real rather than whole numbers and so no two
	// ranges can ever be considered contiguous.
	Contiguous(lower, higher interface{}) bool

	// Return a RangeBoundarySlicer object with given entries and capacity.
	Create(entries, capacity int) RangeBoundarySlicer

	// Parse the string to obtain the numeric values for the range(s)
	// specified.
	Parse(start string, base int, bitSize int) (interface{}, error)

	// Create a new slice element with start and end and append it to the
	// slice.
	Append(start, end interface{}) RangeBoundarySlicer

	// These two don't really belong here - a type switch function would
	// perhaps be more appropriate - as they only use the RangeBoundary to
	// implicitly tell what underlying type to use.
	LessThan(first, second interface{}) bool
	GreaterThan(first, second interface{}) bool
}

Interface for ALL range boundary (<n>rb) types that allows us to have generic handling routines in the compiler for range creation and validation etc.

type Rb

type Rb struct {
	Start, End int64
}

int range boundary (Rb)

func NewRangeBoundary

func NewRangeBoundary(start, end int64) Rb

func (Rb) Error

func (r Rb) Error() string

func (Rb) String

func (r Rb) String() string

func (Rb) Validate

func (r Rb) Validate(i int64) error

type RbSlice

type RbSlice []Rb

Rb RangeBoundarySlicer interface implementation

func (RbSlice) Append

func (rangeBdry RbSlice) Append(start, end interface{}) RangeBoundarySlicer

func (RbSlice) Contiguous

func (rangeBdry RbSlice) Contiguous(lower, higher interface{}) bool

func (RbSlice) Create

func (rangeBdry RbSlice) Create(entries, capacity int) RangeBoundarySlicer

func (RbSlice) GetEnd

func (rangeBdry RbSlice) GetEnd(i int) interface{}

func (RbSlice) GetStart

func (rangeBdry RbSlice) GetStart(i int) interface{}

func (RbSlice) GreaterThan

func (rangeBdry RbSlice) GreaterThan(first, second interface{}) bool

func (RbSlice) Len

func (rangeBdry RbSlice) Len() int

func (RbSlice) LessThan

func (rangeBdry RbSlice) LessThan(first, second interface{}) bool

func (RbSlice) Parse

func (rangeBdry RbSlice) Parse(start string, base int, bitSize int) (interface{}, error)

func (RbSlice) String

func (rangeBdry RbSlice) String(i int) string

type Restriction

type Restriction interface {
	// contains filtered or unexported methods
}

Restrictions

type Rpc

type Rpc interface {
	Input() Tree
	Output() Tree
	// contains filtered or unexported methods
}

func NewRpc

func NewRpc(input, output Tree) Rpc

type SchemaValidator

type SchemaValidator struct {
	// contains filtered or unexported fields
}

func NewSchemaValidator

func NewSchemaValidator(sn Node, c datanode.DataNode) *SchemaValidator

func (*SchemaValidator) SetValidation

func (sv *SchemaValidator) SetValidation(
	valType ValidationType,
) *SchemaValidator

func (*SchemaValidator) Validate

func (sv *SchemaValidator) Validate() ([]*exec.Output, []error, bool)

type Status

type Status int

func (Status) String

func (s Status) String() string

type String

type String interface {
	Type
	Len() *Length
	Pats() [][]Pattern
	PatHelps() [][]string
	// contains filtered or unexported methods
}

func NewString

func NewString(
	name xml.Name,
	pats [][]Pattern,
	pathelps [][]string,
	initlen *Length,
	def string,
	hasDef bool,
) String

type Submodule

type Submodule interface {
	EncodeXML(*xml.Encoder)
	Identifier() string
	Namespace() string
	Data() string
	// contains filtered or unexported methods
}

func NewSubmodule

func NewSubmodule(identifier, namespace, revision, data string) Submodule

type Tree

type Tree interface {
	Node
	// contains filtered or unexported methods
}

func NewTree

func NewTree(children []Node) (Tree, error)

Nothing of substance. Perhaps needs a different type...

type Type

type Type interface {
	Validate(ctx ValidateCtx, path []string, s string) error
	Name() xml.Name

	// Strings (possibly other types) may have an empty string as the default.
	// So, we need to explicitly note the presence / absence of a default
	Default() (string, bool)
	AllowedValues(ctxNode xutils.XpathNode, debug bool) (
		allowedValues []string, err error)
	// contains filtered or unexported methods
}

type Uinteger

type Uinteger interface {
	Number
	Rbs() UrbSlice
	// contains filtered or unexported methods
}

func NewUinteger

func NewUinteger(
	bitSize BitWidth,
	name xml.Name,
	rbs []Urb,
	msg string,
	appTag string,
	def string,
	hasDef bool,
) Uinteger

type Union

type Union interface {
	Type
	Typs() []Type
	MatchType(ctx ValidateCtx, path []string, s string) Type
	// contains filtered or unexported methods
}

func NewUnion

func NewUnion(
	name xml.Name,
	typs []Type,
	def string,
	hasDef bool,
) Union

type Urb

type Urb struct {
	Start, End uint64
}

uint range boundary (Urb)

func NewUnsignedRangeBoundary

func NewUnsignedRangeBoundary(start, end uint64) Urb

func (Urb) Error

func (r Urb) Error() string

func (Urb) String

func (r Urb) String() string

func (Urb) Validate

func (r Urb) Validate(i uint64) error

type UrbSlice

type UrbSlice []Urb

Urb RangeBoundarySlicer interface implementation

func (UrbSlice) Append

func (rangeBdry UrbSlice) Append(start, end interface{}) RangeBoundarySlicer

func (UrbSlice) Contiguous

func (rangeBdry UrbSlice) Contiguous(lower, higher interface{}) bool

func (UrbSlice) Create

func (rangeBdry UrbSlice) Create(entries, capacity int) RangeBoundarySlicer

func (UrbSlice) GetEnd

func (rangeBdry UrbSlice) GetEnd(i int) interface{}

func (UrbSlice) GetStart

func (rangeBdry UrbSlice) GetStart(i int) interface{}

func (UrbSlice) GreaterThan

func (rangeBdry UrbSlice) GreaterThan(first, second interface{}) bool

func (UrbSlice) Len

func (rangeBdry UrbSlice) Len() int

func (UrbSlice) LessThan

func (rangeBdry UrbSlice) LessThan(first, second interface{}) bool

func (UrbSlice) Parse

func (rangeBdry UrbSlice) Parse(start string, base int, bitSize int) (interface{}, error)

func (UrbSlice) String

func (rangeBdry UrbSlice) String(i int) string

type ValidateCtx

type ValidateCtx interface {
	ErrorHelpText() []string
	// For validating paths that could exist, eg when making a NETCONF request
	// for the tree under a non-presence container, we need to allow a path
	// that stops at a non-presence container to be considered valid.  Likewise
	// list names w/o entry name, leaves w/o values.
	AllowIncompletePaths() bool
}

An optional type to be passed into validation to allow extensions to operate

type ValidationType

type ValidationType int
const (
	ValidateAll ValidationType = iota
	DontValidate
	ValidateState
	ValidateConfig
)

type WhenAndMustContext

type WhenAndMustContext struct {
	// Mach is the machine that evaulates the full XPATH logic.
	Mach *xpath.Machine

	// ErrMsg is the error message when the XPATH expression returns false.
	//
	// For 'must', this can be specified in YANG, or a default generated by
	// the compiler.  For 'when', it is always the latter.
	ErrMsg string

	// AppTag is used in the <rpc-error> error-app-tag field in errors sent
	// to NETCONF clients.
	AppTag string

	// PathEvalMach is the machine that checks paths in the XPATH expression.
	PathEvalMach *xpath.Machine
	Namespace    string
}

WhenAndMustContext stores common context for When and Must machines.

type WhenContext

type WhenContext struct {
	WhenAndMustContext

	// RunAsParent indicates whether the machine is run on node or parent.
	//
	// 'when' statements can be added directly under an augment statement. In
	// this case we store the statement on each augmented child, but need to
	// run it using the context (current node) set to the parent node.
	RunAsParent bool
}

func NewWhenContext

func NewWhenContext(
	mach, pathEvalMach *xpath.Machine,
	errMsg string,
	runAsParent bool,
	namespace string,
) WhenContext

type XNode

type XNode struct {
	Node
	// contains filtered or unexported fields
}

func NewXNode

func NewXNode(sn Node, parent *XNode) *XNode

func (*XNode) XChildren

func (xn *XNode) XChildren(
	filter xutils.XFilter,
	sortSpec xutils.SortSpec,
) []xutils.XpathNode

func (*XNode) XIsEphemeral

func (xn *XNode) XIsEphemeral() bool

The way XNodes are created means they must refer to real configured nodes, so cannot be ephemeral

func (*XNode) XIsLeaf

func (xn *XNode) XIsLeaf() bool

func (*XNode) XIsLeafList

func (xn *XNode) XIsLeafList() bool

func (*XNode) XIsNonPresCont

func (xn *XNode) XIsNonPresCont() bool

func (*XNode) XListKeyMatches

func (xn *XNode) XListKeyMatches(key xml.Name, val string) bool

func (*XNode) XListKeys

func (xn *XNode) XListKeys() []xutils.NodeRefKey

func (*XNode) XName

func (xn *XNode) XName() string

func (*XNode) XParent

func (xn *XNode) XParent() xutils.XpathNode

func (*XNode) XPath

func (xn *XNode) XPath() xutils.PathType

func (*XNode) XRoot

func (xn *XNode) XRoot() xutils.XpathNode

func (*XNode) XValue

func (xn *XNode) XValue() string

type YangDebugOption

type YangDebugOption func(*yangValDebugContext)

func MustLogThreshold

func MustLogThreshold(threshold int) YangDebugOption

func ValidationDebug

func ValidationDebug(debug bool) YangDebugOption

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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