mitchell852 closed pull request #2369: To go deletednsseckeys URL: https://github.com/apache/trafficcontrol/pull/2369
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/cdn/dnssec.go b/traffic_ops/traffic_ops_golang/cdn/dnssec.go index 0f2b38534..d65992e1e 100644 --- a/traffic_ops/traffic_ops_golang/cdn/dnssec.go +++ b/traffic_ops/traffic_ops_golang/cdn/dnssec.go @@ -34,6 +34,9 @@ import ( "github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/riaksvc" ) +const CDNDNSSECKeyType = "dnssec" +const DNSSECStatusExisting = "existing" + func CreateDNSSECKeys(w http.ResponseWriter, r *http.Request) { inf, userErr, sysErr, errCode := api.NewInfo(r, nil, nil) if userErr != nil || sysErr != nil { @@ -41,6 +44,7 @@ func CreateDNSSECKeys(w http.ResponseWriter, r *http.Request) { return } defer inf.Close() + req := tc.CDNDNSSECGenerateReq{} if err := api.Parse(r.Body, inf.Tx.Tx, &req); err != nil { api.HandleErr(w, r, http.StatusBadRequest, errors.New("parsing request: "+err.Error()), nil) @@ -58,8 +62,6 @@ func CreateDNSSECKeys(w http.ResponseWriter, r *http.Request) { api.WriteResp(w, r, "Successfully created dnssec keys for "+cdnName) } -const DNSSECStatusExisting = "existing" - func generateStoreDNSSECKeys( tx *sql.Tx, cfg *config.Config, @@ -177,3 +179,33 @@ WHERE cdn.name = $1 } return dses, cdnDomain, nil } + +func DeleteDNSSECKeys(w http.ResponseWriter, r *http.Request) { + inf, userErr, sysErr, errCode := api.NewInfo(r, []string{"name"}, nil) + if userErr != nil || sysErr != nil { + api.HandleErr(w, r, errCode, userErr, sysErr) + return + } + defer inf.Close() + + key := inf.Params["name"] + + riakCluster, err := riaksvc.GetRiakClusterTx(inf.Tx.Tx, inf.Config.RiakAuthOptions) + if err != nil { + api.HandleErr(w, r, http.StatusInternalServerError, nil, errors.New("getting riak cluster: "+err.Error())) + return + } + if err := riakCluster.Start(); err != nil { + api.HandleErr(w, r, http.StatusInternalServerError, nil, errors.New("starting riak cluster: "+err.Error())) + return + } + defer riaksvc.StopCluster(riakCluster) + + if err := riaksvc.DeleteObject(key, CDNDNSSECKeyType, riakCluster); err != nil { + api.HandleErr(w, r, http.StatusInternalServerError, nil, errors.New("deleting cdn dnssec keys: "+err.Error())) + return + } + *inf.CommitTx = true + api.CreateChangeLogRawTx(api.ApiChange, "Deleted DNSSEC keys for CDN "+key, inf.User, inf.Tx.Tx) + api.WriteResp(w, r, "Successfully deleted "+CDNDNSSECKeyType+" for "+key) +} diff --git a/traffic_ops/traffic_ops_golang/routes.go b/traffic_ops/traffic_ops_golang/routes.go index bcf0777fe..0a39db19b 100644 --- a/traffic_ops/traffic_ops_golang/routes.go +++ b/traffic_ops/traffic_ops_golang/routes.go @@ -127,6 +127,7 @@ func Routes(d ServerData) ([]Route, []RawRoute, http.Handler, error) { //CDN: queue updates {1.1, http.MethodPost, `cdns/{id}/queue_update$`, cdn.Queue(d.DB.DB), auth.PrivLevelOperations, Authenticated, nil}, {1.1, http.MethodPost, `cdns/dnsseckeys/generate(\.json)?$`, cdn.CreateDNSSECKeys, auth.PrivLevelAdmin, Authenticated, nil}, + {1.1, http.MethodGet, `cdns/name/{name}/dnsseckeys/delete/?(\.json)?$`, cdn.DeleteDNSSECKeys, auth.PrivLevelAdmin, Authenticated, nil}, //CDN: Monitoring: Traffic Monitor {1.1, http.MethodGet, `cdns/{name}/configs/monitoring(\.json)?$`, monitoringHandler(d.DB), auth.PrivLevelReadOnly, Authenticated, nil}, ---------------------------------------------------------------- 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