rob05c commented on a change in pull request #4790:
URL: https://github.com/apache/trafficcontrol/pull/4790#discussion_r451693534



##########
File path: lib/go-atscfg/hostingdotconfig.go
##########
@@ -74,3 +92,22 @@ func MakeHostingDotConfig(
        text += strings.Join(lines, "")
        return text
 }
+
+func hostingMakeDSTopologies(dses []tc.DeliveryServiceNullable, topologies 
[]tc.Topology) map[tc.DeliveryServiceName]tc.Topology {
+       dsTops := map[tc.DeliveryServiceName]tc.Topology{}
+       topNames := map[string]tc.Topology{}
+       for _, to := range topologies {
+               topNames[to.Name] = to
+       }
+       for _, ds := range dses {
+               if ds.Topology == nil || ds.XMLID == nil {
+                       continue
+               }
+               if to, ok := topNames[*ds.Topology]; ok {
+                       dsTops[tc.DeliveryServiceName(*ds.XMLID)] = to
+               } else if *ds.Topology != "" {
+                       log.Errorln("Making remap.config for Delivery Service 
'" + *ds.XMLID + "': has topology '" + *ds.Topology + "', but that topology 
doesn't exist! Treating as if DS has no Topology!")

Review comment:
       Rather than sending context down, I think it would be cleaner to 
propagate the error up and add the context in the caller. Most of config gen 
doesn't use errors now, because it needed to emulate the Perl in the TO API.
   
   Once that's done, many functions like this will also distinguish between 
fatal and non-fatal errors.
   
   I changed it to "hosting.config" for now, and added a TODO to propagate once 
config gen is returning errors properly.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to