(node string)
| 285 | } |
| 286 | |
| 287 | func (s *dfsState) dfs(node string) []string { |
| 288 | if setutil.Contains(s.visited, node) { |
| 289 | return nil |
| 290 | } |
| 291 | if s.onPath[node] { |
| 292 | // Cycle found — return the chain from node back around. |
| 293 | for i, n := range s.path { |
| 294 | if n == node { |
| 295 | return append([]string(nil), s.path[i:]...) |
| 296 | } |
| 297 | } |
| 298 | return append([]string(nil), s.path...) // fallback: should not happen |
| 299 | } |
| 300 | |
| 301 | s.onPath[node] = true |
| 302 | s.path = append(s.path, node) |
| 303 | |
| 304 | for _, entry := range s.aliasMap[node] { |
| 305 | base, _, _ := strings.Cut(entry, "?") |
| 306 | if isAliasReference(base, s.aliasMap) { |
| 307 | if cycle := s.dfs(base); cycle != nil { |
| 308 | return cycle |
| 309 | } |
| 310 | } |
| 311 | } |
| 312 | |
| 313 | s.path = s.path[:len(s.path)-1] |
| 314 | delete(s.onPath, node) |
| 315 | s.visited[node] = struct{}{} |
| 316 | return nil |
| 317 | } |
| 318 | |
| 319 | // isAliasReference reports whether base is a bare identifier that refers to |
| 320 | // another alias key in the alias map (as opposed to a provider-scoped name or glob). |
no test coverage detected