rawlinp commented on a change in pull request #5922:
URL: https://github.com/apache/trafficcontrol/pull/5922#discussion_r651908234
##########
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:
I believe the original intent was that the latest handler (i.e.
`updateV40/createV40`), would take a V4X struct as input then immediately cast
it to the major version alias, e.g. `DeliveryServiceV4`. That way, all the
other functions take the major version alias as input and don't need updated
with every single new minor version. `UpgradeToV4` upgrades to the major
version struct, but it should probably actually upgrade to the `V40` struct
instead, since it's used in the `updateV31` function. We wouldn't want the
`updateV31` function to upgrade its input to `V41` because that would skip a
link (4.0) in the version upgrade chain.
--
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]