MCPcopy Index your code
hub / github.com/devspace-sh/devspace / RemoveNode

Method RemoveNode

pkg/devspace/dependency/graph/graph.go:84–109  ·  view source on GitHub ↗

RemoveNode removes a node with no children in the graph

(id string)

Source from the content-addressed store, hash-verified

82
83// RemoveNode removes a node with no children in the graph
84func (g *Graph) RemoveNode(id string) error {
85 if node, ok := g.Nodes[id]; ok {
86 if len(node.Childs) > 0 {
87 return errors.Errorf("Cannot remove %s from graph because it has still children", getNameOrID(node))
88 }
89
90 // Remove child from parents
91 for _, parent := range node.Parents {
92 i := -1
93 for idx, c := range parent.Childs {
94 if c.ID == id {
95 i = idx
96 }
97 }
98
99 if i != -1 {
100 parent.Childs = append(parent.Childs[:i], parent.Childs[i+1:]...)
101 }
102 }
103
104 // Remove from graph nodes
105 delete(g.Nodes, id)
106 }
107
108 return nil
109}
110
111// GetNextLeaf returns the next leaf in the graph from node start
112func (g *Graph) GetNextLeaf(start *Node) *Node {

Callers 2

TestGraphFunction · 0.80
orderVariablesMethod · 0.80

Calls 2

getNameOrIDFunction · 0.85
ErrorfMethod · 0.45

Tested by 1

TestGraphFunction · 0.64