Documentation ¶
Index ¶
- Constants
- type Inf
- type Node
- func (n *Node) AllowResource(resType string) bool
- func (n *Node) Exist(ns string) bool
- func (n *Node) GetByID(nodeID string) (*Node, string, error)
- func (n *Node) GetByNS(ns string) (*Node, error)
- func (n *Node) IsLeaf() bool
- func (n *Node) LeafChildIDs() ([]string, error)
- func (n *Node) LeafMachineReg() (map[string]string, error)
- func (n *Node) LeafNs() ([]string, error)
- func (j *Node) MarshalJSON() ([]byte, error)
- func (j *Node) MarshalJSONBuf(buf fflib.EncodingBuffer) error
- func (n *Node) RemoveChildNode(childID string) error
- func (j *Node) UnmarshalJSON(input []byte) error
- func (j *Node) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error
- func (n *Node) Update(name, comment, machineMatchStrategy string)
- func (n *Node) Walk(walkFun WalkfFun) (map[string]string, error)
- type NodeProperty
- type WalkfFun
Constants ¶
const ( // RootNode is the root node name. RootNode = "loda" // PoolNode is the global pool node. PoolNode = "pool" // NodeDeli join node to ns. // e.g The global pool node is the the leaf child of root node, its ns is pool.loda. NodeDeli = "." // NodeDataBucketID is the bucketID to save node data. NodeDataBucketID = "loda" // NodeDataKey is the node data key. NodeDataKey = "node" // NsFormat NsFormat = "ns" // IDFormat IDFormat = "id" // NotMatchMachine is defaul not match machine. NotMatchMachine = "^$" )
const ( // Leaf node type Leaf = iota // leaf type of node // NonLeaf node type NonLeaf // Root type of node Root )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Inf ¶
type Inf interface { // GetNodeByNS return the node by ns. // e.g return root node if get ns "loda". GetNodeByNS(ns string) (*Node, error) // LeafChildIDs return leaf child node ID list of the ns. LeafChildIDs(ns string) ([]string, error) // GetNodeIDByNS return the NS of the node ID. GetNodeIDByNS(ns string) (string, error) // GetNodeNSByID returh the node ID of the ns. GetNodeNSByID(id string) (string, error) // AllNodes return the root node. AllNodes() (*Node, error) }
Inf is the interface node have.
type Node ¶
type Node struct { NodeProperty Children []*Node `json:"children"` }
Node is the item of tree, it has machine match stregy and resource.
func (*Node) AllowResource ¶
AllowResource checks if the node could be set a resource. Leaf node could set/get resource; NonLeaf node could be only set/get template resource.
If check fail, the node is NonLeaf and resType not template, maybe need get/set at its leaf child node.
func (*Node) LeafChildIDs ¶
LeafChildIDs return the leaf id list of this Node.
func (*Node) LeafMachineReg ¶
LeafMachineReg return the ns-MachineReg Map.
func (*Node) MarshalJSON ¶
MarshalJSON marshal bytes to json - template
func (*Node) MarshalJSONBuf ¶
func (j *Node) MarshalJSONBuf(buf fflib.EncodingBuffer) error
MarshalJSONBuf marshal buff to json - template
func (*Node) RemoveChildNode ¶
RemoveChildNode remove the child by node ID.
func (*Node) UnmarshalJSON ¶
UnmarshalJSON umarshall json - template of ffjson
func (*Node) UnmarshalJSONFFLexer ¶
UnmarshalJSONFFLexer fast json unmarshall - template ffjson
type NodeProperty ¶
type NodeProperty struct { ID string `json:"id"` Name string `json:"name"` Comment string `json:"comment"` Type int `json:"type"` // regexp of machine in one node, // used to auto add a machine into nodes MachineReg string `json:"machinereg"` }
NodeProperty is node should has.
func (*NodeProperty) MarshalJSON ¶
func (j *NodeProperty) MarshalJSON() ([]byte, error)
MarshalJSON marshal bytes to json - template
func (*NodeProperty) MarshalJSONBuf ¶
func (j *NodeProperty) MarshalJSONBuf(buf fflib.EncodingBuffer) error
MarshalJSONBuf marshal buff to json - template
func (*NodeProperty) UnmarshalJSON ¶
func (j *NodeProperty) UnmarshalJSON(input []byte) error
UnmarshalJSON umarshall json - template of ffjson
func (*NodeProperty) UnmarshalJSONFFLexer ¶
func (j *NodeProperty) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error
UnmarshalJSONFFLexer fast json unmarshall - template ffjson