Commit 456cb9ce authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'improve-route-order' into 'master'

Improve ordering of routes

See merge request gitlab-org/gitlab!20155
parents 6ebe8eaa 9e8fdc76
# frozen_string_literal: true
# for secondary email confirmations - uses the same confirmation controller as :users
devise_for :emails, path: 'profile/emails', controllers: { confirmations: :confirmations }
......@@ -42,14 +44,6 @@ resource :profile, only: [:show, :update] do
end
end
Gitlab.ee do
resource :slack, only: [:edit] do
member do
get :slack_link
end
end
end
resources :chat_names, only: [:index, :new, :create, :destroy] do
collection do
delete :deny
......@@ -73,10 +67,5 @@ resource :profile, only: [:show, :update] do
end
resources :u2f_registrations, only: [:destroy]
Gitlab.ee do
resources :pipeline_quota, only: [:index]
resources :billings, only: [:index]
end
end
end
resources :projects, only: [:index, :new, :create]
# frozen_string_literal: true
Gitlab.ee do
scope "/-/push_from_secondary/:geo_node_id" do
draw :git_http
end
end
resources :projects, only: [:index, :new, :create]
draw :git_http
......@@ -87,22 +83,12 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
resource :operations, only: [:show, :update]
resource :integrations, only: [:show]
Gitlab.ee do
resource :slack, only: [:destroy, :edit, :update] do
get :slack_auth
end
end
resource :repository, only: [:show], controller: :repository do
post :create_deploy_token, path: 'deploy_token/create'
post :cleanup
end
end
Gitlab.ee do
resources :feature_flags
end
resources :autocomplete_sources, only: [] do
collection do
get 'members'
......@@ -268,16 +254,6 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
namespace :prometheus do
resources :metrics, constraints: { id: %r{[^\/]+} }, only: [:index, :new, :create, :edit, :update, :destroy] do
get :active_common, on: :collection
Gitlab.ee do
post :validate_query, on: :collection
end
end
Gitlab.ee do
resources :alerts, constraints: { id: /\d+/ }, only: [:index, :create, :show, :update, :destroy] do
post :notify, on: :collection
end
end
end
......@@ -290,15 +266,6 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
get :pipeline_status
get :ci_environments_status
post :toggle_subscription
Gitlab.ee do
get :approvals
post :approvals, action: :approve
delete :approvals, action: :unapprove
post :rebase
end
post :remove_wip
post :assign_related_issues
get :discussions, format: :json
......@@ -336,21 +303,6 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
post :bulk_update
end
Gitlab.ee do
resources :approvers, only: :destroy
delete 'approvers', to: 'approvers#destroy_via_user_id', as: :approver_via_user_id
resources :approver_groups, only: :destroy
scope module: :merge_requests do
resources :drafts, only: [:index, :update, :create, :destroy] do
collection do
post :publish
delete :discard
end
end
end
end
resources :discussions, only: [:show], constraints: { id: /\h{40}/ } do
member do
post :resolve
......@@ -381,21 +333,6 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
end
end
Gitlab.ee do
resources :path_locks, only: [:index, :destroy] do
collection do
post :toggle
end
end
get '/service_desk' => 'service_desk#show', as: :service_desk
put '/service_desk' => 'service_desk#update', as: :service_desk_refresh
end
Gitlab.ee do
resources :push_rules, constraints: { id: /\d+/ }, only: [:update]
end
resources :pipelines, only: [:index, :new, :create, :show] do
collection do
resource :pipelines_settings, path: 'settings', only: [:show, :update]
......@@ -414,11 +351,6 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
get :failures
get :status
get :test_report
Gitlab.ee do
get :security
get :licenses
end
end
member do
......@@ -447,21 +379,12 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
get '/terminal.ws/authorize', to: 'environments#terminal_websocket_authorize', constraints: { format: nil }
get '/prometheus/api/v1/*proxy_path', to: 'environments/prometheus_api#proxy', as: :prometheus_api
Gitlab.ee do
get :logs
get '/pods/(:pod_name)/containers/(:container_name)/logs', to: 'environments#k8s_pod_logs', as: :k8s_pod_logs
end
end
collection do
get :metrics, action: :metrics_redirect
get :folder, path: 'folders/*id', constraints: { format: /(html|json)/ }
get :search
Gitlab.ee do
get :logs, action: :logs_redirect
end
end
resources :deployments, only: [:index] do
......@@ -472,14 +395,6 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
end
end
Gitlab.ee do
resources :protected_environments, only: [:create, :update, :destroy], constraints: { id: /\d+/ } do
collection do
get 'search'
end
end
end
namespace :serverless do
scope :functions do
get '/:environment_id/:id', to: 'functions#show'
......@@ -522,14 +437,6 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
end
end
Gitlab.ee do
namespace :security do
resource :dashboard, only: [:show], controller: :dashboard
end
resources :vulnerability_feedback, only: [:index, :create, :update, :destroy], constraints: { id: /\d+/ }
end
get :issues, to: 'issues#calendar', constraints: lambda { |req| req.format == :ics }
resources :issues, concerns: :awardable, constraints: { id: /\d+/ } do
......@@ -543,24 +450,11 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
get :realtime_changes
post :create_merge_request
get :discussions, format: :json
Gitlab.ee do
get 'designs(/*vueroute)', to: 'issues#designs', as: :designs, format: false
end
end
collection do
post :bulk_update
post :import_csv
Gitlab.ee do
post :export_csv
get :service_desk
end
end
Gitlab.ee do
resources :issue_links, only: [:index, :create, :destroy], as: 'links', path: 'links'
end
end
......@@ -595,11 +489,6 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
end
end
Gitlab.ee do
resources :approvers, only: :destroy
resources :approver_groups, only: :destroy
end
resources :runner_projects, only: [:create, :destroy]
resources :badges, only: [:index] do
collection do
......@@ -614,10 +503,6 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
end
end
Gitlab.ee do
resources :audit_events, only: [:index]
end
resources :error_tracking, only: [:index], controller: :error_tracking do
collection do
get ':issue_id/details',
......@@ -639,9 +524,15 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
draw :wiki
draw :repository
Gitlab.ee do
resources :managed_licenses, only: [:index, :show, :new, :create, :edit, :update, :destroy]
end
# Legacy routes.
# Introduced in 12.0.
# Should be removed with https://gitlab.com/gitlab-org/gitlab/issues/28848.
Gitlab::Routing.redirect_legacy_paths(self, :settings, :branches, :tags,
:network, :graphs, :autocomplete_sources,
:project_members, :deploy_keys, :deploy_tokens,
:labels, :milestones, :services, :boards, :releases,
:forks, :group_links, :import, :avatar, :mirror,
:cycle_analytics, :mattermost, :variables, :triggers)
end
resources(:projects,
......@@ -666,23 +557,4 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
end
end
end
# Legacy routes.
# Introduced in 12.0.
# Should be removed with https://gitlab.com/gitlab-org/gitlab/issues/28848.
scope(path: '*namespace_id',
as: :namespace,
namespace_id: Gitlab::PathRegex.full_namespace_route_regex) do
scope(path: ':project_id',
constraints: { project_id: Gitlab::PathRegex.project_route_regex },
module: :projects,
as: :project) do
Gitlab::Routing.redirect_legacy_paths(self, :settings, :branches, :tags,
:network, :graphs, :autocomplete_sources,
:project_members, :deploy_keys, :deploy_tokens,
:labels, :milestones, :services, :boards, :releases,
:forks, :group_links, :import, :avatar, :mirror,
:cycle_analytics, :mattermost, :variables, :triggers)
end
end
end
Gitlab.ee do
get 'unsubscribes/:email', to: 'unsubscribes#show', as: :unsubscribe
post 'unsubscribes/:email', to: 'unsubscribes#create'
end
# frozen_string_literal: true
# Allows individual providers to be directed to a chosen controller
# Call from inside devise_scope
......@@ -30,10 +27,6 @@ devise_for :users, controllers: { omniauth_callbacks: :omniauth_callbacks,
devise_scope :user do
get '/users/auth/:provider/omniauth_error' => 'omniauth_callbacks#omniauth_error', as: :omniauth_error
get '/users/almost_there' => 'confirmations#almost_there'
Gitlab.ee do
get '/users/auth/kerberos_spnego/negotiate' => 'omniauth_kerberos_spnego#negotiate'
end
end
scope '-/users', module: :users do
......
# frozen_string_literal: true
namespace :admin do
resources :users, constraints: { id: %r{[a-zA-Z./0-9_\-]+} } do
resources :users, only: [], constraints: { id: %r{[a-zA-Z./0-9_\-]+} } do
member do
post :reset_runners_minutes
end
......
......@@ -145,14 +145,6 @@ constraints(::Constraints::GroupUrlConstrainer.new) do
resource :roadmap, only: [:show], controller: 'roadmap'
legacy_ee_group_boards_redirect = redirect do |params, request|
path = "/groups/#{params[:group_id]}/-/boards"
path << "/#{params[:extra_params]}" if params[:extra_params].present?
path << "?#{request.query_string}" if request.query_string.present?
path
end
get 'boards(/*extra_params)', as: :legacy_ee_group_boards_redirect, to: legacy_ee_group_boards_redirect
resource :dependency_proxy, only: [:show, :update]
resources :packages, only: [:index]
end
......
# frozen_string_literal: true
resource :profile, only: [] do
scope module: :profiles do
resource :slack, only: [:edit] do
member do
get :slack_link
end
end
resources :pipeline_quota, only: [:index]
resources :billings, only: [:index]
end
end
# frozen_string_literal: true
scope "/-/push_from_secondary/:geo_node_id" do
draw :git_http
end
constraints(::Constraints::ProjectUrlConstrainer.new) do
scope(path: '*namespace_id',
as: :namespace,
......@@ -26,6 +30,7 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
end
end
resources :feature_flags
resource :feature_flags_client, only: [] do
post :reset_token
end
......@@ -37,11 +42,15 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
end
namespace :settings do
resource :operations, only: [:show, :update] do
resource :operations, only: [] do
member do
post :reset_alerting_token
end
end
resource :slack, only: [:destroy, :edit, :update] do
get :slack_auth
end
end
resources :designs, only: [], constraints: { id: /\d+/ } do
......@@ -54,6 +63,22 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
end
# End of the /-/ scope.
resources :path_locks, only: [:index, :destroy] do
collection do
post :toggle
end
end
namespace :prometheus do
resources :alerts, constraints: { id: /\d+/ }, only: [:index, :create, :show, :update, :destroy] do
post :notify, on: :collection
end
resources :metrics, constraints: { id: %r{[^\/]+} }, only: [] do
post :validate_query, on: :collection
end
end
post 'alerts/notify', to: 'alerting/notifications#create'
resource :tracing, only: [:show]
......@@ -72,9 +97,20 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
resources :issues, only: [], constraints: { id: /\d+/ } do
member do
get '/descriptions/:version_id/diff', action: :description_diff, as: :description_diff
get '/designs(/*vueroute)', to: 'issues#designs', as: :designs, format: false
end
collection do
post :export_csv
get :service_desk
end
resources :issue_links, only: [:index, :create, :destroy], as: 'links', path: 'links'
end
get '/service_desk' => 'service_desk#show', as: :service_desk
put '/service_desk' => 'service_desk#update', as: :service_desk_refresh
resources :merge_requests, only: [], constraints: { id: /\d+/ } do
member do
get '/descriptions/:version_id/diff', action: :description_diff, as: :description_diff
......@@ -84,6 +120,36 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
get :dependency_scanning_reports
get :sast_reports
get :dast_reports
get :approvals
post :approvals, action: :approve
delete :approvals, action: :unapprove
post :rebase
end
resources :approvers, only: :destroy
delete 'approvers', to: 'approvers#destroy_via_user_id', as: :approver_via_user_id
resources :approver_groups, only: :destroy
scope module: :merge_requests do
resources :drafts, only: [:index, :update, :create, :destroy] do
collection do
post :publish
delete :discard
end
end
end
end
resources :approvers, only: :destroy
resources :approver_groups, only: :destroy
resources :push_rules, constraints: { id: /\d+/ }, only: [:update]
resources :pipelines, only: [] do
member do
get :security
get :licenses
end
end
......@@ -93,10 +159,8 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
end
end
resource :dependencies, only: [:show]
resource :licenses, only: [:show]
namespace :security do
resource :dashboard, only: [:show], controller: :dashboard
resources :dependencies, only: [:index]
resources :licenses, only: [:index]
# We have to define both legacy and new routes for Vulnerability Findings
......@@ -115,6 +179,31 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
end
end
end
resources :vulnerability_feedback, only: [:index, :create, :update, :destroy], constraints: { id: /\d+/ }
resource :dependencies, only: [:show]
resource :licenses, only: [:show]
resources :managed_licenses, only: [:index, :show, :new, :create, :edit, :update, :destroy]
resources :environments, only: [] do
member do
get :logs
get '/pods/(:pod_name)/containers/(:container_name)/logs', to: 'environments#k8s_pod_logs', as: :k8s_pod_logs
end
collection do
get :logs, action: :logs_redirect
end
end
resources :protected_environments, only: [:create, :update, :destroy], constraints: { id: /\d+/ } do
collection do
get 'search'
end
end
resources :audit_events, only: [:index]
end
end
end
......
# frozen_string_literal: true
get 'unsubscribes/:email', to: 'unsubscribes#show', as: :unsubscribe
post 'unsubscribes/:email', to: 'unsubscribes#create'
devise_scope :user do
get '/users/auth/kerberos_spnego/negotiate' => 'omniauth_kerberos_spnego#negotiate'
end
scope(constraints: { username: Gitlab::PathRegex.root_namespace_route_regex }) do
scope(path: 'users/:username',
as: :user,
......
......@@ -10,7 +10,7 @@ module Gitlab
RoutesNotFound = Class.new(StandardError)
def draw(routes_name)
drawn_any = draw_ce(routes_name) | draw_ee(routes_name)
drawn_any = draw_ee(routes_name) | draw_ce(routes_name)
drawn_any || raise(RoutesNotFound.new("Cannot find #{routes_name}"))
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment