Skip to content

Commit

Permalink
Fixes #38031 - Use the same routes constraints as Foreman
Browse files Browse the repository at this point in the history
  • Loading branch information
ofedoren authored and nofaralfasi committed Nov 27, 2024
1 parent 6a9bae2 commit 6238ea6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -270,3 +270,6 @@ Style/TrailingCommaInArrayLiteral:
# SupportedStylesForMultiline: comma, consistent_comma, no_comma
Style/TrailingCommaInHashLiteral:
Enabled: false

Style/RegexpLiteral:
Enabled: false
14 changes: 7 additions & 7 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 6238ea6

Please sign in to comment.