You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@trafficcontrol.apache.org by GitBox <gi...@apache.org> on 2018/07/24 16:53:41 UTC
[GitHub] dangogh closed pull request #2576: Fixes missing staticdns query
parameters
dangogh closed pull request #2576: Fixes missing staticdns query parameters
URL: https://github.com/apache/trafficcontrol/pull/2576
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/testing/api/v13/staticdnsentries_test.go b/traffic_ops/testing/api/v13/staticdnsentries_test.go
index 3dc8a6a93..3ca74cbfd 100644
--- a/traffic_ops/testing/api/v13/staticdnsentries_test.go
+++ b/traffic_ops/testing/api/v13/staticdnsentries_test.go
@@ -37,8 +37,8 @@ func TestStaticDNSEntries(t *testing.T) {
CreateTestStaticDNSEntries(t)
GetTestStaticDNSEntries(t)
UpdateTestStaticDNSEntries(t)
- DeleteTestDeliveryServices(t)
DeleteTestStaticDNSEntries(t)
+ DeleteTestDeliveryServices(t)
DeleteTestServers(t)
DeleteTestCacheGroups(t)
DeleteTestPhysLocations(t)
@@ -97,7 +97,7 @@ func UpdateTestStaticDNSEntries(t *testing.T) {
t.Errorf("cannot GET StaticDNSEntries by name: '%s', %v\n", firstStaticDNSEntry.Host, err)
}
remoteStaticDNSEntry := resp[0]
- expectedAddress := "address2"
+ expectedAddress := "192.168.0.1"
remoteStaticDNSEntry.Address = expectedAddress
var alert tc.Alerts
alert, _, err = TOSession.UpdateStaticDNSEntryByID(remoteStaticDNSEntry.ID, remoteStaticDNSEntry)
@@ -140,10 +140,10 @@ func DeleteTestStaticDNSEntries(t *testing.T) {
_, _, err := TOSession.DeleteStaticDNSEntryByID(respStaticDNSEntry.ID)
if err != nil {
- t.Errorf("cannot DELETE StaticDNSEntrie by name: '%s' %v\n", respStaticDNSEntry.Host, err)
+ t.Errorf("cannot DELETE StaticDNSEntry by name: '%s' %v\n", respStaticDNSEntry.Host, err)
}
- // Retrieve the StaticDNSEntrie to see if it got deleted
+ // Retrieve the StaticDNSEntry to see if it got deleted
staticDNSEntries, _, err := TOSession.GetStaticDNSEntriesByHost(staticDNSEntry.Host)
if err != nil {
t.Errorf("error deleting StaticDNSEntrie name: %s\n", err.Error())
diff --git a/traffic_ops/testing/api/v13/tc-fixtures.json b/traffic_ops/testing/api/v13/tc-fixtures.json
index e6b7c37e7..e1b221289 100644
--- a/traffic_ops/testing/api/v13/tc-fixtures.json
+++ b/traffic_ops/testing/api/v13/tc-fixtures.json
@@ -1024,7 +1024,7 @@
],
"staticdnsentries": [
{
- "address": "address1",
+ "address": "this.is.a.hostname.",
"cachegroup": "cachegroup1",
"deliveryservice": "ds1",
"host": "host1",
@@ -1032,7 +1032,7 @@
"ttl": 10
},
{
- "address": "address2",
+ "address": "192.168.0.1",
"cachegroup": "cachegroup2",
"deliveryservice": "ds1",
"host": "host2",
@@ -1040,12 +1040,12 @@
"ttl": 10
},
{
- "host": "host3",
- "deliveryservice": "ds1",
+ "address": "2001:0db8:85a3:0000:0000:8a2e:0370:7334",
"cachegroup": "cachegroup2",
- "address": "127.0.0.1",
- "type": "CNAME_RECORD",
- "ttl": 10
+ "deliveryservice": "ds1",
+ "host": "host3",
+ "ttl": 10,
+ "type": "CNAME_RECORD"
}
],
"statuses": [
diff --git a/traffic_ops/traffic_ops_golang/staticdnsentry/staticdnsentry.go b/traffic_ops/traffic_ops_golang/staticdnsentry/staticdnsentry.go
index 5f213b006..744514b33 100644
--- a/traffic_ops/traffic_ops_golang/staticdnsentry/staticdnsentry.go
+++ b/traffic_ops/traffic_ops_golang/staticdnsentry/staticdnsentry.go
@@ -32,6 +32,7 @@ import (
"github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/api"
"github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/dbhelpers"
validation "github.com/go-ozzo/ozzo-validation"
+ "github.com/go-ozzo/ozzo-validation/is"
"github.com/lib/pq"
)
@@ -81,18 +82,27 @@ func (staticDNSEntry *TOStaticDNSEntry) SetKeys(keys map[string]interface{}) {
// Validate fulfills the api.Validator interface
func (staticDNSEntry TOStaticDNSEntry) Validate() error {
errs := validation.Errors{
- "host": validation.Validate(staticDNSEntry.Host, validation.Required),
- "address": validation.Validate(staticDNSEntry.Address, validation.Required),
- "dsname": validation.Validate(staticDNSEntry.DeliveryService, validation.Required),
- "ttl": validation.Validate(staticDNSEntry.TTL, validation.Required),
- "type": validation.Validate(staticDNSEntry.Type, validation.Required),
+ "host": validation.Validate(staticDNSEntry.Host, validation.Required, is.DNSName),
+ "address": validation.Validate(staticDNSEntry.Address, validation.Required, is.Host),
+ "deliveryserviceId": validation.Validate(staticDNSEntry.DeliveryServiceID, validation.Required),
+ "ttl": validation.Validate(staticDNSEntry.TTL, validation.Required),
+ "typeId": validation.Validate(staticDNSEntry.TypeID, validation.Required),
}
return util.JoinErrs(tovalidate.ToErrors(errs))
}
func (staticDNSEntry *TOStaticDNSEntry) Read(parameters map[string]string) ([]interface{}, []error, tc.ApiErrorType) {
queryParamsToQueryCols := map[string]dbhelpers.WhereColumnInfo{
- "deliveryservice": dbhelpers.WhereColumnInfo{"deliveryservice", nil}, // order by
+ "address": dbhelpers.WhereColumnInfo{"sde.address", nil},
+ "cachegroup": dbhelpers.WhereColumnInfo{"cg.name", nil},
+ "cachegroupId": dbhelpers.WhereColumnInfo{"cg.id", nil},
+ "deliveryservice": dbhelpers.WhereColumnInfo{"ds.xml_id", nil},
+ "deliveryserviceId": dbhelpers.WhereColumnInfo{"sde.deliveryservice", nil},
+ "host": dbhelpers.WhereColumnInfo{"sde.host", nil},
+ "id": dbhelpers.WhereColumnInfo{"sde.id", nil},
+ "ttl": dbhelpers.WhereColumnInfo{"sde.ttl", nil},
+ "type": dbhelpers.WhereColumnInfo{"tp.name", nil},
+ "typeId": dbhelpers.WhereColumnInfo{"tp.id", nil},
}
where, orderBy, queryValues, errs := dbhelpers.BuildWhereAndOrderBy(parameters, queryParamsToQueryCols)
if len(errs) > 0 {
----------------------------------------------------------------
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:
users@infra.apache.org
With regards,
Apache Git Services