dewrich closed pull request #2221: Fix TO Go CRConfig to omit null missLocations
URL: https://github.com/apache/incubator-trafficcontrol/pull/2221
 
 
   

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/deliveryservice.go 
b/traffic_ops/traffic_ops_golang/crconfig/deliveryservice.go
index 078487fe9..802cbc54b 100644
--- a/traffic_ops/traffic_ops_golang/crconfig/deliveryservice.go
+++ b/traffic_ops/traffic_ops_golang/crconfig/deliveryservice.go
@@ -105,7 +105,6 @@ and d.active = true
 
        for rows.Next() {
                ds := tc.CRConfigDeliveryService{
-                       MissLocation:    &tc.CRConfigLatitudeLongitudeShort{},
                        Protocol:        &tc.CRConfigDeliveryServiceProtocol{},
                        ResponseHeaders: map[string]string{},
                        Soa:             cdnSOA,
@@ -139,12 +138,13 @@ and d.active = true
                if err := rows.Scan(&xmlID, &missLat, &missLon, &protocol, 
&ds.TTL, &ds.RoutingName, &geoProvider, &ttype, &geoLimit, &geoLimitCountries, 
&geoLimitRedirectURL, &dispersion, &geoBlocking, &trRespHdrsStr, 
&maxDNSAnswers, &profile, &dnsBypassIP, &dnsBypassIP6, &dnsBypassTTL, 
&dnsBypassCName, &httpBypassFQDN, &ip6RoutingEnabled, &deepCachingType, 
&trRequestHeaders, &trResponseHeaders); err != nil {
                        return nil, errors.New("scanning deliveryservice: " + 
err.Error())
                }
-
-               if missLat.Valid {
-                       ds.MissLocation.Lat = missLat.Float64
-               }
-               if missLon.Valid {
-                       ds.MissLocation.Lon = missLon.Float64
+               // TODO prevent (lat XOR lon) in the DB and UI
+               if missLat.Valid && missLon.Valid {
+                       ds.MissLocation = 
&tc.CRConfigLatitudeLongitudeShort{Lat: missLat.Float64, Lon: missLon.Float64}
+               } else if missLat.Valid {
+                       log.Warnln("delivery service " + xmlID + " has miss 
latitude but not longitude: omitting miss lat-lon from CRConfig")
+               } else if missLon.Valid {
+                       log.Warnln("delivery service " + xmlID + " has miss 
longitude but not latitude: omitting miss lat-lon from CRConfig")
                }
                if ttl.Valid {
                        ttl := int(ttl.Int64)


 

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to