mirror of
				https://github.com/k3s-io/kubernetes.git
				synced 2025-10-31 13:50:01 +00:00 
			
		
		
		
	Merge pull request #117327 from humblec/netlink
dependencies: update {vishvananda/netns,xlab/treeprint}
			
			
This commit is contained in:
		
							
								
								
									
										2
									
								
								vendor/github.com/vishvananda/netns/.golangci.yml
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								vendor/github.com/vishvananda/netns/.golangci.yml
									
									
									
										generated
									
									
										vendored
									
									
										Normal file
									
								
							| @@ -0,0 +1,2 @@ | ||||
| run: | ||||
|   timeout: 5m | ||||
							
								
								
									
										11
									
								
								vendor/github.com/vishvananda/netns/README.md
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										11
									
								
								vendor/github.com/vishvananda/netns/README.md
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -49,14 +49,3 @@ func main() { | ||||
| } | ||||
|  | ||||
| ``` | ||||
|  | ||||
| ## NOTE | ||||
|  | ||||
| The library can be safely used only with Go >= 1.10 due to [golang/go#20676](https://github.com/golang/go/issues/20676). | ||||
|  | ||||
| After locking a goroutine to its current OS thread with `runtime.LockOSThread()` | ||||
| and changing its network namespace, any new subsequent goroutine won't be | ||||
| scheduled on that thread while it's locked. Therefore, the new goroutine | ||||
| will run in a different namespace leading to unexpected results. | ||||
|  | ||||
| See [here](https://www.weave.works/blog/linux-namespaces-golang-followup) for more details. | ||||
|   | ||||
							
								
								
									
										9
									
								
								vendor/github.com/vishvananda/netns/netns_linux.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										9
									
								
								vendor/github.com/vishvananda/netns/netns_linux.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -2,7 +2,6 @@ package netns | ||||
|  | ||||
| import ( | ||||
| 	"fmt" | ||||
| 	"io/ioutil" | ||||
| 	"os" | ||||
| 	"path" | ||||
| 	"path/filepath" | ||||
| @@ -136,7 +135,7 @@ func GetFromDocker(id string) (NsHandle, error) { | ||||
|  | ||||
| // borrowed from docker/utils/utils.go | ||||
| func findCgroupMountpoint(cgroupType string) (int, string, error) { | ||||
| 	output, err := ioutil.ReadFile("/proc/mounts") | ||||
| 	output, err := os.ReadFile("/proc/mounts") | ||||
| 	if err != nil { | ||||
| 		return -1, "", err | ||||
| 	} | ||||
| @@ -166,7 +165,7 @@ func findCgroupMountpoint(cgroupType string) (int, string, error) { | ||||
| // borrowed from docker/utils/utils.go | ||||
| // modified to get the docker pid instead of using /proc/self | ||||
| func getDockerCgroup(cgroupVer int, cgroupType string) (string, error) { | ||||
| 	dockerpid, err := ioutil.ReadFile("/var/run/docker.pid") | ||||
| 	dockerpid, err := os.ReadFile("/var/run/docker.pid") | ||||
| 	if err != nil { | ||||
| 		return "", err | ||||
| 	} | ||||
| @@ -178,7 +177,7 @@ func getDockerCgroup(cgroupVer int, cgroupType string) (string, error) { | ||||
| 	if err != nil { | ||||
| 		return "", err | ||||
| 	} | ||||
| 	output, err := ioutil.ReadFile(fmt.Sprintf("/proc/%d/cgroup", pid)) | ||||
| 	output, err := os.ReadFile(fmt.Sprintf("/proc/%d/cgroup", pid)) | ||||
| 	if err != nil { | ||||
| 		return "", err | ||||
| 	} | ||||
| @@ -265,7 +264,7 @@ func getPidForContainer(id string) (int, error) { | ||||
| 		return pid, fmt.Errorf("Unable to find container: %v", id[:len(id)-1]) | ||||
| 	} | ||||
|  | ||||
| 	output, err := ioutil.ReadFile(filename) | ||||
| 	output, err := os.ReadFile(filename) | ||||
| 	if err != nil { | ||||
| 		return pid, err | ||||
| 	} | ||||
|   | ||||
							
								
								
									
										2
									
								
								vendor/github.com/vishvananda/netns/nshandle_linux.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/github.com/vishvananda/netns/nshandle_linux.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -30,7 +30,7 @@ func (ns NsHandle) Equal(other NsHandle) bool { | ||||
| // String shows the file descriptor number and its dev and inode. | ||||
| func (ns NsHandle) String() string { | ||||
| 	if ns == -1 { | ||||
| 		return "NS(None)" | ||||
| 		return "NS(none)" | ||||
| 	} | ||||
| 	var s unix.Stat_t | ||||
| 	if err := unix.Fstat(int(ns), &s); err != nil { | ||||
|   | ||||
							
								
								
									
										2
									
								
								vendor/github.com/vishvananda/netns/nshandle_others.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/github.com/vishvananda/netns/nshandle_others.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -17,7 +17,7 @@ func (ns NsHandle) Equal(_ NsHandle) bool { | ||||
| // It is only implemented on Linux, and returns "NS(none)" on other | ||||
| // platforms. | ||||
| func (ns NsHandle) String() string { | ||||
| 	return "NS(None)" | ||||
| 	return "NS(none)" | ||||
| } | ||||
|  | ||||
| // UniqueId returns a string which uniquely identifies the namespace | ||||
|   | ||||
							
								
								
									
										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{} | ||||
|  | ||||
| // 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. | ||||
| type Tree interface { | ||||
| 	// AddNode adds a new node to a branch. | ||||
| 	// AddNode adds a new Node to a branch. | ||||
| 	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 | ||||
| 	// AddBranch adds a new branch node (a level deeper). | ||||
| 	// AddBranch adds a new branch Node (a level deeper). | ||||
| 	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 | ||||
| 	// Branch converts a leaf-node to a branch-node, | ||||
| 	// applying this on a branch-node does no effect. | ||||
| 	// Branch converts a leaf-Node to a branch-Node, | ||||
| 	// applying this on a branch-Node does no effect. | ||||
| 	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. | ||||
| 	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. | ||||
| 	FindByValue(value Value) Tree | ||||
| 	//  returns the last node of a tree | ||||
| 	//  returns the last Node of a tree | ||||
| 	FindLastNode() Tree | ||||
| 	// String renders the tree or subtree as a string. | ||||
| 	String() string | ||||
| @@ -48,19 +48,19 @@ type Tree interface { | ||||
| 	SetMetaValue(meta MetaValue) | ||||
|  | ||||
| 	// 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. | ||||
| 	VisitAll(fn NodeVisitor) | ||||
| } | ||||
|  | ||||
| type node struct { | ||||
| 	Root  *node | ||||
| type Node struct { | ||||
| 	Root  *Node | ||||
| 	Meta  MetaValue | ||||
| 	Value Value | ||||
| 	Nodes []*node | ||||
| 	Nodes []*Node | ||||
| } | ||||
|  | ||||
| func (n *node) FindLastNode() Tree { | ||||
| func (n *Node) FindLastNode() Tree { | ||||
| 	ns := n.Nodes | ||||
| 	if len(ns) == 0 { | ||||
| 		return nil | ||||
| @@ -68,16 +68,16 @@ func (n *node) FindLastNode() Tree { | ||||
| 	return ns[len(ns)-1] | ||||
| } | ||||
|  | ||||
| func (n *node) AddNode(v Value) Tree { | ||||
| 	n.Nodes = append(n.Nodes, &node{ | ||||
| func (n *Node) AddNode(v Value) Tree { | ||||
| 	n.Nodes = append(n.Nodes, &Node{ | ||||
| 		Root:  n, | ||||
| 		Value: v, | ||||
| 	}) | ||||
| 	return n | ||||
| } | ||||
|  | ||||
| func (n *node) AddMetaNode(meta MetaValue, v Value) Tree { | ||||
| 	n.Nodes = append(n.Nodes, &node{ | ||||
| func (n *Node) AddMetaNode(meta MetaValue, v Value) Tree { | ||||
| 	n.Nodes = append(n.Nodes, &Node{ | ||||
| 		Root:  n, | ||||
| 		Meta:  meta, | ||||
| 		Value: v, | ||||
| @@ -85,8 +85,8 @@ func (n *node) AddMetaNode(meta MetaValue, v Value) Tree { | ||||
| 	return n | ||||
| } | ||||
|  | ||||
| func (n *node) AddBranch(v Value) Tree { | ||||
| 	branch := &node{ | ||||
| func (n *Node) AddBranch(v Value) Tree { | ||||
| 	branch := &Node{ | ||||
| 		Root:  n, | ||||
| 		Value: v, | ||||
| 	} | ||||
| @@ -94,8 +94,8 @@ func (n *node) AddBranch(v Value) Tree { | ||||
| 	return branch | ||||
| } | ||||
|  | ||||
| func (n *node) AddMetaBranch(meta MetaValue, v Value) Tree { | ||||
| 	branch := &node{ | ||||
| func (n *Node) AddMetaBranch(meta MetaValue, v Value) Tree { | ||||
| 	branch := &Node{ | ||||
| 		Root:  n, | ||||
| 		Meta:  meta, | ||||
| 		Value: v, | ||||
| @@ -104,12 +104,12 @@ func (n *node) AddMetaBranch(meta MetaValue, v Value) Tree { | ||||
| 	return branch | ||||
| } | ||||
|  | ||||
| func (n *node) Branch() Tree { | ||||
| func (n *Node) Branch() Tree { | ||||
| 	n.Root = nil | ||||
| 	return n | ||||
| } | ||||
|  | ||||
| func (n *node) FindByMeta(meta MetaValue) Tree { | ||||
| func (n *Node) FindByMeta(meta MetaValue) Tree { | ||||
| 	for _, node := range n.Nodes { | ||||
| 		if reflect.DeepEqual(node.Meta, meta) { | ||||
| 			return node | ||||
| @@ -121,7 +121,7 @@ func (n *node) FindByMeta(meta MetaValue) Tree { | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func (n *node) FindByValue(value Value) Tree { | ||||
| func (n *Node) FindByValue(value Value) Tree { | ||||
| 	for _, node := range n.Nodes { | ||||
| 		if reflect.DeepEqual(node.Value, value) { | ||||
| 			return node | ||||
| @@ -133,7 +133,7 @@ func (n *node) FindByValue(value Value) Tree { | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func (n *node) Bytes() []byte { | ||||
| func (n *Node) Bytes() []byte { | ||||
| 	buf := new(bytes.Buffer) | ||||
| 	level := 0 | ||||
| 	var levelsEnded []int | ||||
| @@ -158,19 +158,19 @@ func (n *node) Bytes() []byte { | ||||
| 	return buf.Bytes() | ||||
| } | ||||
|  | ||||
| func (n *node) String() string { | ||||
| func (n *Node) String() string { | ||||
| 	return string(n.Bytes()) | ||||
| } | ||||
|  | ||||
| func (n *node) SetValue(value Value) { | ||||
| func (n *Node) SetValue(value Value) { | ||||
| 	n.Value = value | ||||
| } | ||||
|  | ||||
| func (n *node) SetMetaValue(meta MetaValue) { | ||||
| func (n *Node) SetMetaValue(meta MetaValue) { | ||||
| 	n.Meta = meta | ||||
| } | ||||
|  | ||||
| func (n *node) VisitAll(fn NodeVisitor) { | ||||
| func (n *Node) VisitAll(fn NodeVisitor) { | ||||
| 	for _, node := range n.Nodes { | ||||
| 		fn(node) | ||||
|  | ||||
| @@ -182,7 +182,7 @@ func (n *node) VisitAll(fn NodeVisitor) { | ||||
| } | ||||
|  | ||||
| func printNodes(wr io.Writer, | ||||
| 	level int, levelsEnded []int, nodes []*node) { | ||||
| 	level int, levelsEnded []int, nodes []*Node) { | ||||
|  | ||||
| 	for i, node := range nodes { | ||||
| 		edge := EdgeTypeMid | ||||
| @@ -198,7 +198,7 @@ func printNodes(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++ { | ||||
| 		if isEnded(levelsEnded, i) { | ||||
| @@ -227,7 +227,7 @@ func isEnded(levelsEnded []int, level int) bool { | ||||
| 	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") | ||||
|  | ||||
| 	// 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. | ||||
| // 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. | ||||
| // 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. | ||||
| func padding(level int, node *node) string { | ||||
| // 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 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 { | ||||
| 	links := make([]string, level+1) | ||||
|  | ||||
| 	for node.Root != nil { | ||||
| @@ -267,8 +267,8 @@ func padding(level int, node *node) string { | ||||
| 	return strings.Join(links, "") | ||||
| } | ||||
|  | ||||
| // isLast checks if the node is the last one in the slice of its parent children | ||||
| func isLast(n *node) bool { | ||||
| // isLast checks if the Node is the last one in the slice of its parent children | ||||
| func isLast(n *Node) bool { | ||||
| 	return n == n.Root.FindLastNode() | ||||
| } | ||||
|  | ||||
| @@ -285,10 +285,10 @@ var IndentSize = 3 | ||||
|  | ||||
| // New Generates new tree | ||||
| func New() Tree { | ||||
| 	return &node{Value: "."} | ||||
| 	return &Node{Value: "."} | ||||
| } | ||||
|  | ||||
| // NewWithRoot Generates new tree with the given root value | ||||
| func NewWithRoot(root Value) Tree { | ||||
| 	return &node{Value: root} | ||||
| 	return &Node{Value: root} | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user