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



##########
File path: lib/go-atscfg/headerrewritedotconfig.go
##########
@@ -39,7 +39,127 @@ const ServiceCategoryHeader = "CDN-SVC"
 
 const MaxOriginConnectionsNoMax = 0 // 0 indicates no limit on origin 
connections
 
-type HeaderRewriteDS struct {
+func MakeHeaderRewriteDotConfig(
+       fileName string,
+       deliveryServices []tc.DeliveryServiceNullableV30,
+       deliveryServiceServers []tc.DeliveryServiceServer,
+       server *tc.ServerNullable,
+       servers []tc.ServerNullable,
+       hdrComment string,
+) (Cfg, error) {
+       warnings := []string{}
+
+       dsName := strings.TrimSuffix(strings.TrimPrefix(fileName, 
HeaderRewritePrefix), ConfigSuffix) // TODO verify prefix and suffix? Perl 
doesn't
+
+       tcDS := tc.DeliveryServiceNullableV30{}
+       for _, ds := range deliveryServices {
+               if ds.XMLID == nil {
+                       warnings = append(warnings, "deliveryServices had DS 
with nil xmlId (name)")
+                       continue
+               }
+               if *ds.XMLID != dsName {
+                       continue
+               }
+               tcDS = ds
+               break
+       }
+       if tcDS.ID == nil {
+               return Cfg{}, makeErr(warnings, "ds '"+dsName+"' not found")
+       }
+
+       if tcDS.CDNName == nil {
+               return Cfg{}, makeErr(warnings, "ds '"+dsName+"' missing cdn")
+       }
+
+       ds, err := headerRewriteDSFromDS(&tcDS)
+       if err != nil {
+               return Cfg{}, makeErr(warnings, "converting ds to config ds: 
"+err.Error())
+       }
+
+       dsServers := filterDSS(deliveryServiceServers, map[int]struct{}{ds.ID: 
{}}, nil)
+
+       dsServerIDs := map[int]struct{}{}
+       for _, dss := range dsServers {
+               if dss.Server == nil || dss.DeliveryService == nil {
+                       continue // TODO warn?

Review comment:
       Yep, same as above, I just missed it. Done




----------------------------------------------------------------
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