MCPcopy Create free account
hub / github.com/coder/coder / dependsOnDevcontainer

Function dependsOnDevcontainer

provisioner/terraform/resources.go:1200–1222  ·  view source on GitHub ↗
(graph *gographviz.Graph, dc *proto.Devcontainer, resourceAgentID string, resource *tfjson.StateResource)

Source from the content-addressed store, hash-verified

1198}
1199
1200func 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.
1202 if dc.SubagentId == "" && resourceAgentID == "" {
1203 resourceNodeSuffix := fmt.Sprintf(`] %s.%s (expand)"`, resource.Type, resource.Name)
1204 agentNodeSuffix := fmt.Sprintf(`] coder_devcontainer.%s (expand)"`, dc.Name)
1205
1206 // Traverse the graph to check if the coder_<resource_type> depends on coder_devcontainer.
1207 for _, dst := range graph.Edges.SrcToDsts {
1208 for _, edges := range dst {
1209 for _, edge := range edges {
1210 if strings.HasSuffix(edge.Src, resourceNodeSuffix) &&
1211 strings.HasSuffix(edge.Dst, agentNodeSuffix) {
1212 return true
1213 }
1214 }
1215 }
1216 }
1217 return false
1218 }
1219
1220 // Provision: subagent ID and child resource ID are present
1221 return dc.SubagentId == resourceAgentID
1222}
1223
1224type graphResource struct {
1225 Label string

Callers 1

ConvertStateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected