You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by mi...@apache.org on 2018/05/02 16:39:45 UTC
[incubator-trafficcontrol] branch master updated: Fix TO CRConfig
domain to use CDN table, not param
This is an automated email from the ASF dual-hosted git repository.
mitchell852 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-trafficcontrol.git
The following commit(s) were added to refs/heads/master by this push:
new 43966a9 Fix TO CRConfig domain to use CDN table, not param
43966a9 is described below
commit 43966a9ac623ca25ce31d980267b7ce9b656b920
Author: Robert Butts <ro...@apache.org>
AuthorDate: Wed May 2 10:29:35 2018 -0600
Fix TO CRConfig domain to use CDN table, not param
---
traffic_ops/traffic_ops_golang/crconfig/config.go | 3 ++-
traffic_ops/traffic_ops_golang/crconfig/crconfig.go | 4 ++--
traffic_ops/traffic_ops_golang/crconfig/deliveryservice.go | 14 +++-----------
3 files changed, 7 insertions(+), 14 deletions(-)
diff --git a/traffic_ops/traffic_ops_golang/crconfig/config.go b/traffic_ops/traffic_ops_golang/crconfig/config.go
index ffe3126..0d3eb45 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 44c5ea9..bb85a2f 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 0bc15dd..078487f 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{}{},
--
To stop receiving notification emails like this one, please contact
mitchell852@apache.org.