| 1174 | } |
| 1175 | |
| 1176 | func dependsOnAgent(graph *gographviz.Graph, agent *proto.Agent, resourceAgentID string, resource *tfjson.StateResource) bool { |
| 1177 | // Plan: we need to find if there is edge between the agent and the resource. |
| 1178 | if agent.Id == "" && resourceAgentID == "" { |
| 1179 | resourceNodeSuffix := fmt.Sprintf(`] %s.%s (expand)"`, resource.Type, resource.Name) |
| 1180 | agentNodeSuffix := fmt.Sprintf(`] coder_agent.%s (expand)"`, agent.Name) |
| 1181 | |
| 1182 | // Traverse the graph to check if the coder_<resource_type> depends on coder_agent. |
| 1183 | for _, dst := range graph.Edges.SrcToDsts { |
| 1184 | for _, edges := range dst { |
| 1185 | for _, edge := range edges { |
| 1186 | if strings.HasSuffix(edge.Src, resourceNodeSuffix) && |
| 1187 | strings.HasSuffix(edge.Dst, agentNodeSuffix) { |
| 1188 | return true |
| 1189 | } |
| 1190 | } |
| 1191 | } |
| 1192 | } |
| 1193 | return false |
| 1194 | } |
| 1195 | |
| 1196 | // Provision: agent ID and child resource ID are present |
| 1197 | return agent.Id == resourceAgentID |
| 1198 | } |
| 1199 | |
| 1200 | func dependsOnDevcontainer(graph *gographviz.Graph, dc *proto.Devcontainer, resourceAgentID string, resource *tfjson.StateResource) bool { |
| 1201 | // Plan: we need to find if there is an edge between the resource and the devcontainer. |