ocket8888 commented on a change in pull request #5922:
URL: https://github.com/apache/trafficcontrol/pull/5922#discussion_r651802698
##########
File path: traffic_ops/traffic_ops_golang/deliveryservice/deliveryservices.go
##########
@@ -875,70 +1052,82 @@ WHERE
&dsV31.MaxRequestHeaderBytes,
); err != nil {
if err == sql.ErrNoRows {
- return nil, http.StatusNotFound, fmt.Errorf("delivery
service ID %d not found", *dsV31.ID), nil
+ return nil, tc.Alerts{}, http.StatusNotFound,
fmt.Errorf("delivery service ID %d not found", *dsV31.ID), nil
}
- return nil, http.StatusInternalServerError, nil,
fmt.Errorf("querying delivery service ID %d: %s", *dsV31.ID, err.Error())
+ return nil, tc.Alerts{}, http.StatusInternalServerError, nil,
fmt.Errorf("querying delivery service ID %d: %s", *dsV31.ID, err.Error())
}
- res, status, userErr, sysErr := updateV31(w, r, inf, &dsV31)
+ res, alerts, status, userErr, sysErr := updateV31(w, r, inf, &dsV31)
if res != nil {
- return &res.DeliveryServiceV30, status, userErr, sysErr
+ return &res.DeliveryServiceV30, alerts, status, userErr, sysErr
}
- return nil, status, userErr, sysErr
+ return nil, alerts, status, userErr, sysErr
}
-func updateV31(w http.ResponseWriter, r *http.Request, inf *api.APIInfo, dsV31
*tc.DeliveryServiceV31) (*tc.DeliveryServiceV31, int, error, error) {
+func updateV31(w http.ResponseWriter, r *http.Request, inf *api.APIInfo, dsV31
*tc.DeliveryServiceV31) (*tc.DeliveryServiceV31, tc.Alerts, int, error, error) {
+ var alerts tc.Alerts
+
dsNull := tc.DeliveryServiceNullableV30(*dsV31)
ds := dsNull.UpgradeToV4()
- dsV40 := tc.DeliveryServiceV40(ds)
+ dsV40 := ds
+ if dsV40.ID == nil {
Review comment:
Got it. Also, though, it seems like the only reason `dsV40` exists is as
an unnecessary typecast of `ds` to `tc.DeliveryServiceV40` - do you think it's
safe to just get rid of it and just use `ds` instead? I wasn't totally sure.
--
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]