You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficcontrol.apache.org by de...@apache.org on 2018/08/21 22:08:43 UTC
[trafficcontrol] 01/03: Fix TO Go cdn dnssec generate to accept
numbers
This is an automated email from the ASF dual-hosted git repository.
dewrich pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficcontrol.git
commit 6bff0410e2d3093a8530d283dadf7fe65e346a28
Author: Robert Butts <ro...@apache.org>
AuthorDate: Mon Aug 20 16:27:54 2018 -0600
Fix TO Go cdn dnssec generate to accept numbers
The docs say they're strings, but it appears Perl accepts both,
and the Portal sends numbers. This changes Go to emulate the Perl.
Fixes #2716
---
lib/go-tc/deliveryservice_ssl_keys.go | 10 +++++-----
traffic_ops/traffic_ops_golang/cdn/dnssec.go | 7 ++++---
2 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/lib/go-tc/deliveryservice_ssl_keys.go b/lib/go-tc/deliveryservice_ssl_keys.go
index dbb0edd..a26d672 100644
--- a/lib/go-tc/deliveryservice_ssl_keys.go
+++ b/lib/go-tc/deliveryservice_ssl_keys.go
@@ -156,11 +156,11 @@ type CDNDNSSECGenerateReq struct {
// Key is the CDN name, as documented in the API documentation.
Key *string `json:"key"`
// Name is the CDN domain, as documented in the API documentation.
- Name *string `json:"name"`
- TTL *uint64 `json:"ttl,string"`
- KSKExpirationDays *uint64 `json:"kskExpirationDays,string"`
- ZSKExpirationDays *uint64 `json:"zskExpirationDays,string"`
- EffectiveDateUnix *int64 `json:"effectiveDate"`
+ Name *string `json:"name"`
+ TTL *util.JSONIntStr `json:"ttl"`
+ KSKExpirationDays *util.JSONIntStr `json:"kskExpirationDays"`
+ ZSKExpirationDays *util.JSONIntStr `json:"zskExpirationDays"`
+ EffectiveDateUnix *util.JSONIntStr `json:"effectiveDate"`
}
func (r CDNDNSSECGenerateReq) Validate(tx *sql.Tx) error {
diff --git a/traffic_ops/traffic_ops_golang/cdn/dnssec.go b/traffic_ops/traffic_ops_golang/cdn/dnssec.go
index d65992e..3456620 100644
--- a/traffic_ops/traffic_ops_golang/cdn/dnssec.go
+++ b/traffic_ops/traffic_ops_golang/cdn/dnssec.go
@@ -51,10 +51,11 @@ func CreateDNSSECKeys(w http.ResponseWriter, r *http.Request) {
return
}
if req.EffectiveDateUnix == nil {
- req.EffectiveDateUnix = util.Int64Ptr(time.Now().Unix())
+ now := util.JSONIntStr(time.Now().Unix())
+ req.EffectiveDateUnix = &now
}
cdnName := *req.Key
- if err := generateStoreDNSSECKeys(inf.Tx.Tx, inf.Config, cdnName, *req.TTL, *req.KSKExpirationDays, *req.ZSKExpirationDays, *req.EffectiveDateUnix); err != nil {
+ if err := generateStoreDNSSECKeys(inf.Tx.Tx, inf.Config, cdnName, uint64(*req.TTL), uint64(*req.KSKExpirationDays), uint64(*req.ZSKExpirationDays), int64(*req.EffectiveDateUnix)); err != nil {
api.HandleErr(w, r, http.StatusInternalServerError, nil, errors.New("generating and storing DNSSEC CDN keys: "+err.Error()))
return
}
@@ -167,7 +168,7 @@ WHERE cdn.name = $1
for rows.Next() {
ds := CDNDS{}
dsTypeStr := ""
- if err := rows.Scan(&ds.Name, &ds.Protocol, dsTypeStr, &ds.RoutingName, &cdnDomain); err != nil {
+ if err := rows.Scan(&ds.Name, &ds.Protocol, &dsTypeStr, &ds.RoutingName, &cdnDomain); err != nil {
return nil, "", errors.New("scanning cdn delivery services: " + err.Error())
}
dsType := tc.DSTypeFromString(dsTypeStr)