in pkg/cloud/rgraph/builder.go [108:137]
func (g *Builder) validate() error {
for _, n := range g.nodes {
// No nodes have OwnershipUnknown
if n.Ownership() == rnode.OwnershipUnknown {
return fmt.Errorf("%s: node %s has ownership %s", builderErrPrefix, n.ID(), n.Ownership())
}
// ResourceID is not mismatched
resource := n.Resource()
if resource != nil && !resource.ResourceID().Equal(n.ID()) {
return fmt.Errorf("%s: node and resource id mismatch (node=%v, id=%v)", builderErrPrefix, n.ID(), resource.ResourceID())
}
}
// All resources have their dependencies in the graph if they are OwnershipManaged.
for _, n := range g.nodes {
if n.Ownership() != rnode.OwnershipManaged {
continue
}
deps, err := n.OutRefs()
if err != nil {
return err
}
for _, d := range deps {
if _, ok := g.nodes[d.To.MapKey()]; !ok {
return fmt.Errorf("%s: missing outRef: %v points to %v which isn't in the graph", builderErrPrefix, n.ID(), d.To)
}
}
}
return nil
}