func()

in internal/meta/config_info.go [113:143]


func (cfgs ConfigInfos) addParentChildDependency() {
	for i, cfg := range cfgs {
		parentId := cfg.AzureResourceID.Parent()

		// This resource is either a root scope or a root scoped resource
		if parentId == nil {
			// Root scope: ignore as it has no parent
			if cfg.AzureResourceID.ParentScope() == nil {
				continue
			}
			// Root scoped resource: use its parent scope as its parent
			parentId = cfg.AzureResourceID.ParentScope()
		} else if parentId.Parent() == nil {
			// The cfg reosurce is the RP 1st level resource, we regard its parent scope as its parent
			parentId = cfg.AzureResourceID.ParentScope()
		}

		// Adding the direct parent resource as its dependency
		for _, ocfg := range cfgs {
			if cfg.AzureResourceID.Equal(ocfg.AzureResourceID) {
				continue
			}
			if parentId.Equal(ocfg.AzureResourceID) {
				id := ocfg.AzureResourceID.String()
				cfg.DependsOn = []Dependency{{Candidates: []string{id}}}
				cfgs[i] = cfg
				break
			}
		}
	}
}