From b05fa02da45968f59ef5132eedddc3dc367e361c Mon Sep 17 00:00:00 2001 From: Oleh Fedorenko Date: Thu, 21 Nov 2024 16:02:54 +0000 Subject: [PATCH] Fixes #38031 - Use the same routes constraints as Foreman --- .rubocop_todo.yml | 3 +++ config/routes.rb | 14 +++++++------- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index c03a7ad2..553be51e 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -270,3 +270,6 @@ Style/TrailingCommaInArrayLiteral: # SupportedStylesForMultiline: comma, consistent_comma, no_comma Style/TrailingCommaInHashLiteral: Enabled: false + +Style/RegexpLiteral: + Enabled: false diff --git a/config/routes.rb b/config/routes.rb index 22e3899c..4a8e7138 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -7,14 +7,14 @@ :defaults => { apiv: 'v2' }, :apiv => /v2/, :constraints => ApiConstraints.new(version: 2, default: true) do - constraints(:id => %r{[^\/]+}) do - resources :hosts, :except => [:new, :edit] do + constraints(:id => /[^\/]+/) do + resources :hosts, :only => [] do member do post :play_roles get :ansible_roles post :assign_ansible_roles - put 'ansible_roles/:ansible_role_id', :to => 'hosts#add_ansible_role', :constraints => { id: %r{[^\/]+} } - delete 'ansible_roles/:ansible_role_id', :to => 'hosts#remove_ansible_role', :constraints => { id: %r{[^\/]+} } + put 'ansible_roles/:ansible_role_id', :to => 'hosts#add_ansible_role', :constraints => { id: /[^\/]+/ } + delete 'ansible_roles/:ansible_role_id', :to => 'hosts#remove_ansible_role', :constraints => { id: /[^\/]+/ } end collection do post :multiple_play_roles @@ -25,8 +25,8 @@ post :play_roles get :ansible_roles post :assign_ansible_roles - put 'ansible_roles/:ansible_role_id', :to => 'hostgroups#add_ansible_role', :constraints => { id: %r{[^\/]+} } - delete 'ansible_roles/:ansible_role_id', :to => 'hostgroups#remove_ansible_role', :constraints => { id: %r{[^\/]+} } + put 'ansible_roles/:ansible_role_id', :to => 'hostgroups#add_ansible_role', :constraints => { id: /[^\/]+/ } + delete 'ansible_roles/:ansible_role_id', :to => 'hostgroups#remove_ansible_role', :constraints => { id: /[^\/]+/ } end collection do post :multiple_play_roles @@ -36,7 +36,7 @@ end end scope '/ansible' do - constraints(:id => %r{[^\/]+}) do + constraints(:id => /[^\/]+/) do resources :hosts, :only => [] do member do get :play_roles