mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-09 12:07:47 +00:00
dependencies: xlab/treeprint v1.2.0
Signed-off-by: Humble Chirammal <humble.devassy@gmail.com>
This commit is contained in:
parent
6320b6843a
commit
6b70710b0d
2
go.mod
2
go.mod
@ -215,7 +215,7 @@ require (
|
|||||||
github.com/tmc/grpc-websocket-proxy v0.0.0-20220101234140-673ab2c3ae75 // indirect
|
github.com/tmc/grpc-websocket-proxy v0.0.0-20220101234140-673ab2c3ae75 // indirect
|
||||||
github.com/vishvananda/netns v0.0.4 // indirect
|
github.com/vishvananda/netns v0.0.4 // indirect
|
||||||
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 // indirect
|
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 // indirect
|
||||||
github.com/xlab/treeprint v1.1.0 // indirect
|
github.com/xlab/treeprint v1.2.0 // indirect
|
||||||
go.etcd.io/bbolt v1.3.6 // indirect
|
go.etcd.io/bbolt v1.3.6 // indirect
|
||||||
go.etcd.io/etcd/client/v2 v2.305.7 // indirect
|
go.etcd.io/etcd/client/v2 v2.305.7 // indirect
|
||||||
go.etcd.io/etcd/pkg/v3 v3.5.7 // indirect
|
go.etcd.io/etcd/pkg/v3 v3.5.7 // indirect
|
||||||
|
4
go.sum
4
go.sum
@ -679,8 +679,8 @@ github.com/vmware/govmomi v0.30.0 h1:Fm8ugPnnlMSTSceDKY9goGvjmqc6eQLPUSUeNXdpeXA
|
|||||||
github.com/vmware/govmomi v0.30.0/go.mod h1:F7adsVewLNHsW/IIm7ziFURaXDaHEwcc+ym4r3INMdY=
|
github.com/vmware/govmomi v0.30.0/go.mod h1:F7adsVewLNHsW/IIm7ziFURaXDaHEwcc+ym4r3INMdY=
|
||||||
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 h1:eY9dn8+vbi4tKz5Qo6v2eYzo7kUS51QINcR5jNpbZS8=
|
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 h1:eY9dn8+vbi4tKz5Qo6v2eYzo7kUS51QINcR5jNpbZS8=
|
||||||
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
|
github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU=
|
||||||
github.com/xlab/treeprint v1.1.0 h1:G/1DjNkPpfZCFt9CSh6b5/nY4VimlbHF3Rh4obvtzDk=
|
github.com/xlab/treeprint v1.2.0 h1:HzHnuAF1plUN2zGlAFHbSQP2qJ0ZAD3XF5XD7OesXRQ=
|
||||||
github.com/xlab/treeprint v1.1.0/go.mod h1:gj5Gd3gPdKtR1ikdDK6fnFLdmIS0X30kTTuNd/WEJu0=
|
github.com/xlab/treeprint v1.2.0/go.mod h1:gj5Gd3gPdKtR1ikdDK6fnFLdmIS0X30kTTuNd/WEJu0=
|
||||||
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
|
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
|
||||||
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
|
@ -52,7 +52,7 @@ require (
|
|||||||
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
|
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
|
||||||
github.com/pkg/errors v0.9.1 // indirect
|
github.com/pkg/errors v0.9.1 // indirect
|
||||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||||
github.com/xlab/treeprint v1.1.0 // indirect
|
github.com/xlab/treeprint v1.2.0 // indirect
|
||||||
go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5 // indirect
|
go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5 // indirect
|
||||||
golang.org/x/net v0.8.0 // indirect
|
golang.org/x/net v0.8.0 // indirect
|
||||||
golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b // indirect
|
golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b // indirect
|
||||||
|
4
staging/src/k8s.io/cli-runtime/go.sum
generated
4
staging/src/k8s.io/cli-runtime/go.sum
generated
@ -199,8 +199,8 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO
|
|||||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||||
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
|
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
|
||||||
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||||
github.com/xlab/treeprint v1.1.0 h1:G/1DjNkPpfZCFt9CSh6b5/nY4VimlbHF3Rh4obvtzDk=
|
github.com/xlab/treeprint v1.2.0 h1:HzHnuAF1plUN2zGlAFHbSQP2qJ0ZAD3XF5XD7OesXRQ=
|
||||||
github.com/xlab/treeprint v1.1.0/go.mod h1:gj5Gd3gPdKtR1ikdDK6fnFLdmIS0X30kTTuNd/WEJu0=
|
github.com/xlab/treeprint v1.2.0/go.mod h1:gj5Gd3gPdKtR1ikdDK6fnFLdmIS0X30kTTuNd/WEJu0=
|
||||||
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
|
@ -78,7 +78,7 @@ require (
|
|||||||
github.com/opencontainers/go-digest v1.0.0 // indirect
|
github.com/opencontainers/go-digest v1.0.0 // indirect
|
||||||
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
|
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
|
||||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||||
github.com/xlab/treeprint v1.1.0 // indirect
|
github.com/xlab/treeprint v1.2.0 // indirect
|
||||||
go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5 // indirect
|
go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5 // indirect
|
||||||
golang.org/x/net v0.8.0 // indirect
|
golang.org/x/net v0.8.0 // indirect
|
||||||
golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b // indirect
|
golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b // indirect
|
||||||
|
4
staging/src/k8s.io/kubectl/go.sum
generated
4
staging/src/k8s.io/kubectl/go.sum
generated
@ -247,8 +247,8 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO
|
|||||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||||
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
|
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
|
||||||
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||||
github.com/xlab/treeprint v1.1.0 h1:G/1DjNkPpfZCFt9CSh6b5/nY4VimlbHF3Rh4obvtzDk=
|
github.com/xlab/treeprint v1.2.0 h1:HzHnuAF1plUN2zGlAFHbSQP2qJ0ZAD3XF5XD7OesXRQ=
|
||||||
github.com/xlab/treeprint v1.1.0/go.mod h1:gj5Gd3gPdKtR1ikdDK6fnFLdmIS0X30kTTuNd/WEJu0=
|
github.com/xlab/treeprint v1.2.0/go.mod h1:gj5Gd3gPdKtR1ikdDK6fnFLdmIS0X30kTTuNd/WEJu0=
|
||||||
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
|
@ -41,7 +41,7 @@ require (
|
|||||||
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
|
||||||
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
|
github.com/peterbourgon/diskv v2.0.1+incompatible // indirect
|
||||||
github.com/pkg/errors v0.9.1 // indirect
|
github.com/pkg/errors v0.9.1 // indirect
|
||||||
github.com/xlab/treeprint v1.1.0 // indirect
|
github.com/xlab/treeprint v1.2.0 // indirect
|
||||||
go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5 // indirect
|
go.starlark.net v0.0.0-20200306205701-8dd3e2ee1dd5 // indirect
|
||||||
golang.org/x/net v0.8.0 // indirect
|
golang.org/x/net v0.8.0 // indirect
|
||||||
golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b // indirect
|
golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b // indirect
|
||||||
|
4
staging/src/k8s.io/sample-cli-plugin/go.sum
generated
4
staging/src/k8s.io/sample-cli-plugin/go.sum
generated
@ -198,8 +198,8 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
|
|||||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||||
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||||
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
|
github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8=
|
||||||
github.com/xlab/treeprint v1.1.0 h1:G/1DjNkPpfZCFt9CSh6b5/nY4VimlbHF3Rh4obvtzDk=
|
github.com/xlab/treeprint v1.2.0 h1:HzHnuAF1plUN2zGlAFHbSQP2qJ0ZAD3XF5XD7OesXRQ=
|
||||||
github.com/xlab/treeprint v1.1.0/go.mod h1:gj5Gd3gPdKtR1ikdDK6fnFLdmIS0X30kTTuNd/WEJu0=
|
github.com/xlab/treeprint v1.2.0/go.mod h1:gj5Gd3gPdKtR1ikdDK6fnFLdmIS0X30kTTuNd/WEJu0=
|
||||||
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
|
3
vendor/github.com/xlab/treeprint/.gitignore
generated
vendored
Normal file
3
vendor/github.com/xlab/treeprint/.gitignore
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
vendor/**
|
||||||
|
.idea
|
||||||
|
**/**.iml
|
84
vendor/github.com/xlab/treeprint/treeprint.go
generated
vendored
84
vendor/github.com/xlab/treeprint/treeprint.go
generated
vendored
@ -16,28 +16,28 @@ type Value interface{}
|
|||||||
type MetaValue interface{}
|
type MetaValue interface{}
|
||||||
|
|
||||||
// NodeVisitor function type for iterating over nodes
|
// NodeVisitor function type for iterating over nodes
|
||||||
type NodeVisitor func(item *node)
|
type NodeVisitor func(item *Node)
|
||||||
|
|
||||||
// Tree represents a tree structure with leaf-nodes and branch-nodes.
|
// Tree represents a tree structure with leaf-nodes and branch-nodes.
|
||||||
type Tree interface {
|
type Tree interface {
|
||||||
// AddNode adds a new node to a branch.
|
// AddNode adds a new Node to a branch.
|
||||||
AddNode(v Value) Tree
|
AddNode(v Value) Tree
|
||||||
// AddMetaNode adds a new node with meta value provided to a branch.
|
// AddMetaNode adds a new Node with meta value provided to a branch.
|
||||||
AddMetaNode(meta MetaValue, v Value) Tree
|
AddMetaNode(meta MetaValue, v Value) Tree
|
||||||
// AddBranch adds a new branch node (a level deeper).
|
// AddBranch adds a new branch Node (a level deeper).
|
||||||
AddBranch(v Value) Tree
|
AddBranch(v Value) Tree
|
||||||
// AddMetaBranch adds a new branch node (a level deeper) with meta value provided.
|
// AddMetaBranch adds a new branch Node (a level deeper) with meta value provided.
|
||||||
AddMetaBranch(meta MetaValue, v Value) Tree
|
AddMetaBranch(meta MetaValue, v Value) Tree
|
||||||
// Branch converts a leaf-node to a branch-node,
|
// Branch converts a leaf-Node to a branch-Node,
|
||||||
// applying this on a branch-node does no effect.
|
// applying this on a branch-Node does no effect.
|
||||||
Branch() Tree
|
Branch() Tree
|
||||||
// FindByMeta finds a node whose meta value matches the provided one by reflect.DeepEqual,
|
// FindByMeta finds a Node whose meta value matches the provided one by reflect.DeepEqual,
|
||||||
// returns nil if not found.
|
// returns nil if not found.
|
||||||
FindByMeta(meta MetaValue) Tree
|
FindByMeta(meta MetaValue) Tree
|
||||||
// FindByValue finds a node whose value matches the provided one by reflect.DeepEqual,
|
// FindByValue finds a Node whose value matches the provided one by reflect.DeepEqual,
|
||||||
// returns nil if not found.
|
// returns nil if not found.
|
||||||
FindByValue(value Value) Tree
|
FindByValue(value Value) Tree
|
||||||
// returns the last node of a tree
|
// returns the last Node of a tree
|
||||||
FindLastNode() Tree
|
FindLastNode() Tree
|
||||||
// String renders the tree or subtree as a string.
|
// String renders the tree or subtree as a string.
|
||||||
String() string
|
String() string
|
||||||
@ -48,19 +48,19 @@ type Tree interface {
|
|||||||
SetMetaValue(meta MetaValue)
|
SetMetaValue(meta MetaValue)
|
||||||
|
|
||||||
// VisitAll iterates over the tree, branches and nodes.
|
// VisitAll iterates over the tree, branches and nodes.
|
||||||
// If need to iterate over the whole tree, use the root node.
|
// If need to iterate over the whole tree, use the root Node.
|
||||||
// Note this method uses a breadth-first approach.
|
// Note this method uses a breadth-first approach.
|
||||||
VisitAll(fn NodeVisitor)
|
VisitAll(fn NodeVisitor)
|
||||||
}
|
}
|
||||||
|
|
||||||
type node struct {
|
type Node struct {
|
||||||
Root *node
|
Root *Node
|
||||||
Meta MetaValue
|
Meta MetaValue
|
||||||
Value Value
|
Value Value
|
||||||
Nodes []*node
|
Nodes []*Node
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *node) FindLastNode() Tree {
|
func (n *Node) FindLastNode() Tree {
|
||||||
ns := n.Nodes
|
ns := n.Nodes
|
||||||
if len(ns) == 0 {
|
if len(ns) == 0 {
|
||||||
return nil
|
return nil
|
||||||
@ -68,16 +68,16 @@ func (n *node) FindLastNode() Tree {
|
|||||||
return ns[len(ns)-1]
|
return ns[len(ns)-1]
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *node) AddNode(v Value) Tree {
|
func (n *Node) AddNode(v Value) Tree {
|
||||||
n.Nodes = append(n.Nodes, &node{
|
n.Nodes = append(n.Nodes, &Node{
|
||||||
Root: n,
|
Root: n,
|
||||||
Value: v,
|
Value: v,
|
||||||
})
|
})
|
||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *node) AddMetaNode(meta MetaValue, v Value) Tree {
|
func (n *Node) AddMetaNode(meta MetaValue, v Value) Tree {
|
||||||
n.Nodes = append(n.Nodes, &node{
|
n.Nodes = append(n.Nodes, &Node{
|
||||||
Root: n,
|
Root: n,
|
||||||
Meta: meta,
|
Meta: meta,
|
||||||
Value: v,
|
Value: v,
|
||||||
@ -85,8 +85,8 @@ func (n *node) AddMetaNode(meta MetaValue, v Value) Tree {
|
|||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *node) AddBranch(v Value) Tree {
|
func (n *Node) AddBranch(v Value) Tree {
|
||||||
branch := &node{
|
branch := &Node{
|
||||||
Root: n,
|
Root: n,
|
||||||
Value: v,
|
Value: v,
|
||||||
}
|
}
|
||||||
@ -94,8 +94,8 @@ func (n *node) AddBranch(v Value) Tree {
|
|||||||
return branch
|
return branch
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *node) AddMetaBranch(meta MetaValue, v Value) Tree {
|
func (n *Node) AddMetaBranch(meta MetaValue, v Value) Tree {
|
||||||
branch := &node{
|
branch := &Node{
|
||||||
Root: n,
|
Root: n,
|
||||||
Meta: meta,
|
Meta: meta,
|
||||||
Value: v,
|
Value: v,
|
||||||
@ -104,12 +104,12 @@ func (n *node) AddMetaBranch(meta MetaValue, v Value) Tree {
|
|||||||
return branch
|
return branch
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *node) Branch() Tree {
|
func (n *Node) Branch() Tree {
|
||||||
n.Root = nil
|
n.Root = nil
|
||||||
return n
|
return n
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *node) FindByMeta(meta MetaValue) Tree {
|
func (n *Node) FindByMeta(meta MetaValue) Tree {
|
||||||
for _, node := range n.Nodes {
|
for _, node := range n.Nodes {
|
||||||
if reflect.DeepEqual(node.Meta, meta) {
|
if reflect.DeepEqual(node.Meta, meta) {
|
||||||
return node
|
return node
|
||||||
@ -121,7 +121,7 @@ func (n *node) FindByMeta(meta MetaValue) Tree {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *node) FindByValue(value Value) Tree {
|
func (n *Node) FindByValue(value Value) Tree {
|
||||||
for _, node := range n.Nodes {
|
for _, node := range n.Nodes {
|
||||||
if reflect.DeepEqual(node.Value, value) {
|
if reflect.DeepEqual(node.Value, value) {
|
||||||
return node
|
return node
|
||||||
@ -133,7 +133,7 @@ func (n *node) FindByValue(value Value) Tree {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *node) Bytes() []byte {
|
func (n *Node) Bytes() []byte {
|
||||||
buf := new(bytes.Buffer)
|
buf := new(bytes.Buffer)
|
||||||
level := 0
|
level := 0
|
||||||
var levelsEnded []int
|
var levelsEnded []int
|
||||||
@ -158,19 +158,19 @@ func (n *node) Bytes() []byte {
|
|||||||
return buf.Bytes()
|
return buf.Bytes()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *node) String() string {
|
func (n *Node) String() string {
|
||||||
return string(n.Bytes())
|
return string(n.Bytes())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *node) SetValue(value Value) {
|
func (n *Node) SetValue(value Value) {
|
||||||
n.Value = value
|
n.Value = value
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *node) SetMetaValue(meta MetaValue) {
|
func (n *Node) SetMetaValue(meta MetaValue) {
|
||||||
n.Meta = meta
|
n.Meta = meta
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *node) VisitAll(fn NodeVisitor) {
|
func (n *Node) VisitAll(fn NodeVisitor) {
|
||||||
for _, node := range n.Nodes {
|
for _, node := range n.Nodes {
|
||||||
fn(node)
|
fn(node)
|
||||||
|
|
||||||
@ -182,7 +182,7 @@ func (n *node) VisitAll(fn NodeVisitor) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func printNodes(wr io.Writer,
|
func printNodes(wr io.Writer,
|
||||||
level int, levelsEnded []int, nodes []*node) {
|
level int, levelsEnded []int, nodes []*Node) {
|
||||||
|
|
||||||
for i, node := range nodes {
|
for i, node := range nodes {
|
||||||
edge := EdgeTypeMid
|
edge := EdgeTypeMid
|
||||||
@ -198,7 +198,7 @@ func printNodes(wr io.Writer,
|
|||||||
}
|
}
|
||||||
|
|
||||||
func printValues(wr io.Writer,
|
func printValues(wr io.Writer,
|
||||||
level int, levelsEnded []int, edge EdgeType, node *node) {
|
level int, levelsEnded []int, edge EdgeType, node *Node) {
|
||||||
|
|
||||||
for i := 0; i < level; i++ {
|
for i := 0; i < level; i++ {
|
||||||
if isEnded(levelsEnded, i) {
|
if isEnded(levelsEnded, i) {
|
||||||
@ -227,7 +227,7 @@ func isEnded(levelsEnded []int, level int) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func renderValue(level int, node *node) Value {
|
func renderValue(level int, node *Node) Value {
|
||||||
lines := strings.Split(fmt.Sprintf("%v", node.Value), "\n")
|
lines := strings.Split(fmt.Sprintf("%v", node.Value), "\n")
|
||||||
|
|
||||||
// If value does not contain multiple lines, return itself.
|
// If value does not contain multiple lines, return itself.
|
||||||
@ -248,10 +248,10 @@ func renderValue(level int, node *node) Value {
|
|||||||
|
|
||||||
// padding returns a padding for the multiline values with correctly placed link edges.
|
// padding returns a padding for the multiline values with correctly placed link edges.
|
||||||
// It is generated by traversing the tree upwards (from leaf to the root of the tree)
|
// It is generated by traversing the tree upwards (from leaf to the root of the tree)
|
||||||
// and, on each level, checking if the node the last one of its siblings.
|
// and, on each level, checking if the Node the last one of its siblings.
|
||||||
// If a node is the last one, the padding on that level should be empty (there's nothing to link to below it).
|
// If a Node is the last one, the padding on that level should be empty (there's nothing to link to below it).
|
||||||
// If a node is not the last one, the padding on that level should be the link edge so the sibling below is correctly connected.
|
// If a Node is not the last one, the padding on that level should be the link edge so the sibling below is correctly connected.
|
||||||
func padding(level int, node *node) string {
|
func padding(level int, node *Node) string {
|
||||||
links := make([]string, level+1)
|
links := make([]string, level+1)
|
||||||
|
|
||||||
for node.Root != nil {
|
for node.Root != nil {
|
||||||
@ -267,8 +267,8 @@ func padding(level int, node *node) string {
|
|||||||
return strings.Join(links, "")
|
return strings.Join(links, "")
|
||||||
}
|
}
|
||||||
|
|
||||||
// isLast checks if the node is the last one in the slice of its parent children
|
// isLast checks if the Node is the last one in the slice of its parent children
|
||||||
func isLast(n *node) bool {
|
func isLast(n *Node) bool {
|
||||||
return n == n.Root.FindLastNode()
|
return n == n.Root.FindLastNode()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -285,10 +285,10 @@ var IndentSize = 3
|
|||||||
|
|
||||||
// New Generates new tree
|
// New Generates new tree
|
||||||
func New() Tree {
|
func New() Tree {
|
||||||
return &node{Value: "."}
|
return &Node{Value: "."}
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewWithRoot Generates new tree with the given root value
|
// NewWithRoot Generates new tree with the given root value
|
||||||
func NewWithRoot(root Value) Tree {
|
func NewWithRoot(root Value) Tree {
|
||||||
return &node{Value: root}
|
return &Node{Value: root}
|
||||||
}
|
}
|
||||||
|
2
vendor/modules.txt
vendored
2
vendor/modules.txt
vendored
@ -719,7 +719,7 @@ github.com/vmware/govmomi/vim25/xml
|
|||||||
# github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2
|
# github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2
|
||||||
## explicit
|
## explicit
|
||||||
github.com/xiang90/probing
|
github.com/xiang90/probing
|
||||||
# github.com/xlab/treeprint v1.1.0
|
# github.com/xlab/treeprint v1.2.0
|
||||||
## explicit; go 1.13
|
## explicit; go 1.13
|
||||||
github.com/xlab/treeprint
|
github.com/xlab/treeprint
|
||||||
# go.etcd.io/bbolt v1.3.6
|
# go.etcd.io/bbolt v1.3.6
|
||||||
|
Loading…
Reference in New Issue
Block a user