mitchell852 closed pull request #2215: Fix Traffic Ops Golang CRConfig domain 
to use CDN table, not param
URL: https://github.com/apache/incubator-trafficcontrol/pull/2215
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/traffic_ops/traffic_ops_golang/crconfig/config.go 
b/traffic_ops/traffic_ops_golang/crconfig/config.go
index ffe3126a4..0d3eb4501 100644
--- a/traffic_ops/traffic_ops_golang/crconfig/config.go
+++ b/traffic_ops/traffic_ops_golang/crconfig/config.go
@@ -25,11 +25,12 @@ import (
        "strings"
 )
 
-func makeCRConfigConfig(cdn string, db *sql.DB, dnssecEnabled bool) 
(map[string]interface{}, error) {
+func makeCRConfigConfig(cdn string, db *sql.DB, dnssecEnabled bool, domain 
string) (map[string]interface{}, error) {
        configParams, err := getConfigParams(cdn, db)
        if err != nil {
                return nil, errors.New("Error getting router params: " + 
err.Error())
        }
+       configParams["domain_name"] = domain
        soa := map[string]string{}
        ttl := map[string]string{}
        const soaPrefix = "tld.soa."
diff --git a/traffic_ops/traffic_ops_golang/crconfig/crconfig.go 
b/traffic_ops/traffic_ops_golang/crconfig/crconfig.go
index 44c5ea9cb..bb85a2f1b 100644
--- a/traffic_ops/traffic_ops_golang/crconfig/crconfig.go
+++ b/traffic_ops/traffic_ops_golang/crconfig/crconfig.go
@@ -35,7 +35,7 @@ func Make(db *sql.DB, cdn, user, toHost, reqPath, toVersion 
string) (*tc.CRConfi
                return nil, errors.New("Error getting CDN info: " + err.Error())
        }
 
-       if crc.Config, err = makeCRConfigConfig(cdn, db, dnssecEnabled); err != 
nil {
+       if crc.Config, err = makeCRConfigConfig(cdn, db, dnssecEnabled, 
cdnDomain); err != nil {
                return nil, errors.New("Error getting Config: " + err.Error())
        }
 
@@ -45,7 +45,7 @@ func Make(db *sql.DB, cdn, user, toHost, reqPath, toVersion 
string) (*tc.CRConfi
        if crc.EdgeLocations, crc.RouterLocations, err = makeLocations(cdn, 
db); err != nil {
                return nil, errors.New("Error getting Edge Locations: " + 
err.Error())
        }
-       if crc.DeliveryServices, err = makeDSes(cdn, db); err != nil {
+       if crc.DeliveryServices, err = makeDSes(cdn, cdnDomain, db); err != nil 
{
                return nil, errors.New("Error getting Delivery Services: " + 
err.Error())
        }
 
diff --git a/traffic_ops/traffic_ops_golang/crconfig/deliveryservice.go 
b/traffic_ops/traffic_ops_golang/crconfig/deliveryservice.go
index 0bc15ddc6..078487fe9 100644
--- a/traffic_ops/traffic_ops_golang/crconfig/deliveryservice.go
+++ b/traffic_ops/traffic_ops_golang/crconfig/deliveryservice.go
@@ -41,7 +41,7 @@ const DefaultTLDTTLNS = 3600 * time.Second
 const GeoProviderMaxmindStr = "maxmindGeolocationService"
 const GeoProviderNeustarStr = "neustarGeolocationService"
 
-func makeDSes(cdn string, db *sql.DB) (map[string]tc.CRConfigDeliveryService, 
error) {
+func makeDSes(cdn string, domain string, db *sql.DB) 
(map[string]tc.CRConfigDeliveryService, error) {
        dses := map[string]tc.CRConfigDeliveryService{}
 
        admin := CDNSOAAdmin
@@ -93,7 +93,7 @@ and d.active = true
                return nil, errors.New("getting deliveryservice server 
parameters: " + err.Error())
        }
 
-       dsmatchsets, dsdomains, err := getDSRegexesDomains(cdn, db, dsParams)
+       dsmatchsets, dsdomains, err := getDSRegexesDomains(cdn, domain, db)
        if err != nil {
                return nil, errors.New("getting regex matchsets: " + 
err.Error())
        }
@@ -373,12 +373,10 @@ func getProtocolStr(dsType string) string {
        return "HTTP"
 }
 
-func getDSRegexesDomains(cdn string, db *sql.DB, dsParams map[string]string) 
(map[string][]*tc.MatchSet, map[string][]string, error) {
+func getDSRegexesDomains(cdn string, domain string, db *sql.DB) 
(map[string][]*tc.MatchSet, map[string][]string, error) {
        dsmatchsets := map[string][]*tc.MatchSet{}
        domains := map[string][]string{}
-
        patternToHostReplacer := strings.NewReplacer(`\`, ``, `.*`, ``, `.`, ``)
-
        q := `
 select r.pattern, t.name as type, dt.name as dstype, COALESCE(dr.set_number, 
0), d.xml_id as dsname
 from regex as r
@@ -432,11 +430,6 @@ order by dr.set_number asc
                matchset.Protocol = protocolStr
                matchset.MatchList = append(matchset.MatchList, 
tc.MatchList{MatchType: matchType, Regex: pattern})
 
-               domain := ""
-               if val, ok := dsParams["domain_name"]; ok {
-                       domain = val
-               }
-
                if ttype == "HOST_REGEXP" && setnum == 0 {
                        domains[dsname] = append(domains[dsname], 
patternToHostReplacer.Replace(pattern)+"."+domain)
                }
@@ -449,7 +442,6 @@ order by dr.set_number asc
 // If any profiles have conflicting parameters, an error is returned.
 func getDSParams(serverParams map[string]map[string]string) 
(map[string]string, error) {
        dsParamNames := map[string]struct{}{
-               "domain_name":       struct{}{},
                "tld.soa.admin":     struct{}{},
                "tld.soa.expire":    struct{}{},
                "tld.soa.minimum":   struct{}{},


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to