MCPcopy
hub / github.com/docker/compose / WithRootNodesAndDown

Function WithRootNodesAndDown

pkg/compose/dependencies.go:104–130  ·  view source on GitHub ↗
(nodes []string)

Source from the content-addressed store, hash-verified

102}
103
104func WithRootNodesAndDown(nodes []string) func(*graphTraversal) {
105 return func(t *graphTraversal) {
106 if len(nodes) == 0 {
107 return
108 }
109 originalFn := t.extremityNodesFn
110 t.extremityNodesFn = func(graph *Graph) []*Vertex {
111 var want []string
112 for _, node := range nodes {
113 vertex := graph.Vertices[node]
114 want = append(want, vertex.Service)
115 for _, v := range getAncestors(vertex) {
116 want = append(want, v.Service)
117 }
118 }
119
120 t.ignored = map[string]struct{}{}
121 for k := range graph.Vertices {
122 if !slices.Contains(want, k) {
123 t.ignored[k] = struct{}{}
124 }
125 }
126
127 return originalFn(graph)
128 }
129 }
130}
131
132func (t *graphTraversal) visit(ctx context.Context, g *Graph) error {
133 expect := len(g.Vertices)

Callers 2

TestWith_RootNodesAndUpFunction · 0.85
downMethod · 0.85

Calls 1

getAncestorsFunction · 0.85

Tested by 1

TestWith_RootNodesAndUpFunction · 0.68