in pkg/brownfield/routing_rules.go [180:221]
func (er ExistingResources) getRuleToTargets() (ruleToTargets, pathmapToTargets) {
ruleToTargets := make(ruleToTargets)
pathMapToTargets := make(pathmapToTargets)
for _, rule := range er.RoutingRules {
if rule.HTTPListener == nil || rule.HTTPListener.ID == nil {
continue
}
HostNames, err := er.getHostNamesForRoutingRule(rule)
if err != nil {
klog.Errorf("[brownfield] Could not obtain hostname for rule %s; Skipping rule", ruleName(*rule.Name))
continue
}
for _, hostName := range HostNames {
// Regardless of whether we have a URL PathMap or not. This matches the default backend pool.
ruleToTargets[ruleName(*rule.Name)] = append(ruleToTargets[ruleName(*rule.Name)], Target{
Hostname: hostName,
// Path deliberately omitted
})
}
// SSL Redirects do not have BackendAddressPool
if rule.URLPathMap != nil {
// Follow the path map
pathMapName, pathRules := er.getPathRules(rule)
for _, pathRule := range pathRules {
if pathRule.Paths == nil {
klog.V(3).Infof("[brownfield] Path Rule %+v does not have paths list", *pathRule.Name)
continue
}
for _, path := range *pathRule.Paths {
for _, hostName := range HostNames {
target := Target{hostName, TargetPath(path)}
ruleToTargets[ruleName(*rule.Name)] = append(ruleToTargets[ruleName(*rule.Name)], target)
pathMapToTargets[pathMapName] = append(pathMapToTargets[pathMapName], target)
}
}
}
}
}
return ruleToTargets, pathMapToTargets
}