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

Method visit

pkg/compose/dependencies.go:425–444  ·  view source on GitHub ↗
(key string, path []string, discovered []string, finished []string)

Source from the content-addressed store, hash-verified

423}
424
425func (g *Graph) visit(key string, path []string, discovered []string, finished []string) ([]string, []string, error) {
426 discovered = append(discovered, key)
427
428 for _, v := range g.Vertices[key].Children {
429 path := append(path, v.Key)
430 if slices.Contains(discovered, v.Key) {
431 return nil, nil, fmt.Errorf("cycle found: %s", strings.Join(path, " -> "))
432 }
433
434 if !slices.Contains(finished, v.Key) {
435 if _, _, err := g.visit(v.Key, path, discovered, finished); err != nil {
436 return nil, nil, err
437 }
438 }
439 }
440
441 discovered = slices.DeleteFunc(discovered, func(s string) bool { return s == key })
442 finished = append(finished, key)
443 return discovered, finished, nil
444}

Callers 4

HasCyclesMethod · 0.95
TestWith_RootNodesAndUpFunction · 0.45
InDependencyOrderFunction · 0.45
InReverseDependencyOrderFunction · 0.45

Calls

no outgoing calls

Tested by 1

TestWith_RootNodesAndUpFunction · 0.36