ocket8888 commented on a change in pull request #3534: TP Delivery Service
Generate SSL update, new letsencrypt generate and…
URL: https://github.com/apache/trafficcontrol/pull/3534#discussion_r339174543
##########
File path: traffic_ops/traffic_ops_golang/deliveryservice/keys.go
##########
@@ -210,9 +218,75 @@ func getSSLKeysByXMLIDHelper(xmlID string, inf
*api.APIInfo, w http.ResponseWrit
return
}
}
+
api.WriteResp(w, r, keyObj)
}
+// GetSSLKeysByXMLID fetches the deliveryservice ssl keys by the specified
xmlID.
+func GetSSLKeysByXMLIDV14(w http.ResponseWriter, r *http.Request) {
+ inf, userErr, sysErr, errCode := api.NewInfo(r, []string{"xmlid"}, nil)
+ if userErr != nil || sysErr != nil {
+ api.HandleErr(w, r, inf.Tx.Tx, errCode, userErr, sysErr)
+ return
+ }
+ defer inf.Close()
+ if inf.Config.RiakEnabled == false {
+ api.HandleErr(w, r, inf.Tx.Tx, http.StatusServiceUnavailable,
errors.New("the Riak service is unavailable"), errors.New("getting SSL keys
from Riak by xml id: Riak is not configured"))
+ return
+ }
+ xmlID := inf.Params["xmlid"]
+ getSSLKeysByXMLIDHelperV14(xmlID, inf, w, r)
+}
+
+func getSSLKeysByXMLIDHelperV14(xmlID string, inf *api.APIInfo, w
http.ResponseWriter, r *http.Request) {
+ version := inf.Params["version"]
+ decode := inf.Params["decode"]
+ if userErr, sysErr, errCode := tenant.Check(inf.User, xmlID,
inf.Tx.Tx); userErr != nil || sysErr != nil {
+ api.HandleErr(w, r, inf.Tx.Tx, errCode, userErr, sysErr)
+ return
+ }
+ keyObj, ok, err := riaksvc.GetDeliveryServiceSSLKeysObjV14(xmlID,
version, inf.Tx.Tx, inf.Config.RiakAuthOptions, inf.Config.RiakPort)
+ if err != nil {
+ api.HandleErr(w, r, inf.Tx.Tx, http.StatusInternalServerError,
nil, errors.New("getting ssl keys: "+err.Error()))
+ return
+ }
+ if !ok {
+ api.WriteRespAlertObj(w, r, tc.InfoLevel, "no object found for
the specified key", struct{}{}) // empty response object because Perl
Review comment:
I think what you're looking for in that case is
[`api.WriteRespAlert`](https://godoc.org/github.com/apache/trafficcontrol/traffic_ops/traffic_ops_golang/api#WriteRespAlert)
- unless you're trying to get `"response": {}` in the response?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services