mhoppa commented on a change in pull request #4406: Only allow changing of
types based on useintable
URL: https://github.com/apache/trafficcontrol/pull/4406#discussion_r391828111
##########
File path: traffic_ops/traffic_ops_golang/types/types.go
##########
@@ -95,9 +98,48 @@ func (typ *TOType) Validate() error {
}
func (tp *TOType) Read() ([]interface{}, error, error, int) { return
api.GenericRead(tp) }
-func (tp *TOType) Update() (error, error, int) { return
api.GenericUpdate(tp) }
-func (tp *TOType) Create() (error, error, int) { return
api.GenericCreate(tp) }
-func (tp *TOType) Delete() (error, error, int) { return
api.GenericDelete(tp) }
+
+func (tp *TOType) Update() (error, error, int) {
+ if !tp.AllowMutation() {
+ return nil, errors.New("can not update type"),
http.StatusBadRequest
+ }
+ return api.GenericUpdate(tp)
+}
+
+func (tp *TOType) Delete() (error, error, int) {
+ if tp.UseInTable == nil {
Review comment:
when I try to delete an ID that doesnt exist I am getting
```
ERROR: api.go:789: 2020-03-12T18:53:41.8901632Z: a non-pq error was given
ERROR: api.go:173: 2020-03-12T18:53:41.8916858Z: 172.28.0.1:60308 sql: no
rows in result set
DEBUG: api.go:178: 2020-03-12T18:53:41.8918061Z: Internal Server Error
```
are you getting the same?
Also wont `tp.UseInTable == nil` always be nil? since the object isnt passed
in on request?
----------------------------------------------------------------
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