zrhoffman commented on code in PR #7309: URL: https://github.com/apache/trafficcontrol/pull/7309#discussion_r1085643375
########## traffic_ops/app/db/migrations/2023012316280200_create_new_role_to_user.up.sql: ########## @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with this + * work for additional information regarding copyright ownership. The ASF + * licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +INSERT INTO public."role" +(id, name, description, priv_level, last_updated) +VALUES(236, 'trouter', 'Role utilized by the trouter user', 30, '2023-01-11 18:18:11.800'); Review Comment: > Role utilized by the trouter user General Apache Traffic Control users don't know what a `trouter` user is, maybe rephrase in terms of what the role can be used for? ########## traffic_ops/app/db/migrations/2023012316280200_create_new_role.down.sql: ########## @@ -0,0 +1,22 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with this + * work for additional information regarding copyright ownership. The ASF + * licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +DELETE FROM public.role_capability rc WHERE rc.role_id='trouter' + ON CONFLICT DO NOTHING; Review Comment: Migrations should not have `ON CONFLICT DO NOTHING`, we keep track of migration version the DB is at, and if it runs unnecessarily, we *do* want to see the conflict, because that should never happen. ########## traffic_ops/app/db/migrations/2023012316280200_create_new_role.up.sql: ########## @@ -0,0 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with this + * work for additional information regarding copyright ownership. The ASF + * licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +INSERT INTO public."role" (name, description, priv_level) +VALUES('trouter', 'Limited role for Traffic Router calls to Traffic Ops', 10); + +INSERT INTO public.role_capability (role_id, cap_name) + VALUES ((select id from role where name='trouter'), UNNEST('{CDN:READ, DELIVERY-SERVICE:READ, DNS-SEC:READ, FEDERATION:READ, STEERING:READ, FEDERATION-RESOLVER:READ, DS-SECURITY-KEY:READ}'::text[])) + ON CONFLICT DO NOTHING; Review Comment: `ON CONFLICT DO NOTHING` should be removed ########## traffic_ops/app/db/migrations/2023012316280200_create_new_role.up.sql: ########## @@ -0,0 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with this + * work for additional information regarding copyright ownership. The ASF + * licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +INSERT INTO public."role" (name, description, priv_level) +VALUES('trouter', 'Limited role for Traffic Router calls to Traffic Ops', 10); + +INSERT INTO public.role_capability (role_id, cap_name) + VALUES ((select id from role where name='trouter'), UNNEST('{CDN:READ, DELIVERY-SERVICE:READ, DNS-SEC:READ, FEDERATION:READ, STEERING:READ, FEDERATION-RESOLVER:READ, DS-SECURITY-KEY:READ}'::text[])) Review Comment: Nit: `select`, `from`, `where`, and `text` should be capitalized like the other SQL keywords. ########## traffic_ops/app/db/migrations/2023012316280200_create_new_role.down.sql: ########## @@ -0,0 +1,22 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with this + * work for additional information regarding copyright ownership. The ASF + * licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +DELETE FROM public.role_capability rc WHERE rc.role_id='trouter' + ON CONFLICT DO NOTHING; + +DELETE FROM public."role" r WHERE r.name='trouter' + ON CONFLICT DO NOTHING; Review Comment: Another place where `ON CONFLICT DO NOTHING` should be removed ########## traffic_ops/app/db/migrations/2023012316280200_create_new_role_to_user.up.sql: ########## @@ -0,0 +1,43 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with this + * work for additional information regarding copyright ownership. The ASF + * licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +INSERT INTO public."role" +(id, name, description, priv_level, last_updated) +VALUES(236, 'trouter', 'Role utilized by the trouter user', 30, '2023-01-11 18:18:11.800'); Review Comment: No need for `id` or `last_updated` ########## traffic_ops/app/db/migrations/2023012316280200_create_new_role.up.sql: ########## @@ -0,0 +1,23 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with this + * work for additional information regarding copyright ownership. The ASF + * licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ + +INSERT INTO public."role" (name, description, priv_level) +VALUES('trouter', 'Limited role for Traffic Router calls to Traffic Ops', 10); + +INSERT INTO public.role_capability (role_id, cap_name) + VALUES ((select id from role where name='trouter'), UNNEST('{CDN:READ, DELIVERY-SERVICE:READ, DNS-SEC:READ, FEDERATION:READ, STEERING:READ, FEDERATION-RESOLVER:READ, DS-SECURITY-KEY:READ}'::text[])) + ON CONFLICT DO NOTHING; Review Comment: In order to be POSIX-compliant, every file should end with a newline. -- 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. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
