shamrickus 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_r393314926
##########
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:
You are correct, at the time of writing i was confused as to how the generic
CRUD was working. I'll remove it in my upcoming changes.
----------------------------------------------------------------
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