Commit 305dedf9 authored by Jan Provaznik's avatar Jan Provaznik

Merge branch 'dz-move-operations-routes' into 'master'

Move operations project routes under - scope

See merge request gitlab-org/gitlab!20456
parents 56b39912 aac1cdf4
---
title: Move operations project routes under - scope
merge_request: 20456
author:
type: deprecated
......@@ -209,6 +209,55 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
get :production
end
end
concerns :clusterable
namespace :serverless do
scope :functions do
get '/:environment_id/:id', to: 'functions#show'
get '/:environment_id/:id/metrics', to: 'functions#metrics', as: :metrics
end
resources :functions, only: [:index]
end
resources :environments, except: [:destroy] do
member do
post :stop
get :terminal
get :metrics
get :additional_metrics
get :metrics_dashboard
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
end
collection do
get :metrics, action: :metrics_redirect
get :folder, path: 'folders/*id', constraints: { format: /(html|json)/ }
get :search
end
resources :deployments, only: [:index] do
member do
get :metrics
get :additional_metrics
end
end
end
resources :error_tracking, only: [:index], controller: :error_tracking do
collection do
get ':issue_id/details',
to: 'error_tracking#details',
as: 'details'
get ':issue_id/stack_trace',
to: 'error_tracking#stack_trace',
as: 'stack_trace'
post :list_projects
end
end
end
# End of the /-/ scope.
......@@ -373,43 +422,6 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
end
end
concerns :clusterable
resources :environments, except: [:destroy] do
member do
post :stop
get :terminal
get :metrics
get :additional_metrics
get :metrics_dashboard
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
end
collection do
get :metrics, action: :metrics_redirect
get :folder, path: 'folders/*id', constraints: { format: /(html|json)/ }
get :search
end
resources :deployments, only: [:index] do
member do
get :metrics
get :additional_metrics
end
end
end
namespace :serverless do
scope :functions do
get '/:environment_id/:id', to: 'functions#show'
get '/:environment_id/:id/metrics', to: 'functions#metrics', as: :metrics
end
resources :functions, only: [:index]
end
draw :legacy_builds
resources :hooks, only: [:index, :create, :edit, :update, :destroy], constraints: { id: /\d+/ } do
......@@ -507,18 +519,6 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
end
end
resources :error_tracking, only: [:index], controller: :error_tracking do
collection do
get ':issue_id/details',
to: 'error_tracking#details',
as: 'details'
get ':issue_id/stack_trace',
to: 'error_tracking#stack_trace',
as: 'stack_trace'
post :list_projects
end
end
scope :usage_ping, controller: :usage_ping do
post :web_ide_clientside_preview
end
......@@ -540,7 +540,9 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
:project_members, :deploy_keys, :deploy_tokens,
:labels, :milestones, :services, :boards, :releases,
:forks, :group_links, :import, :avatar, :mirror,
:cycle_analytics, :mattermost, :variables, :triggers)
:cycle_analytics, :mattermost, :variables, :triggers,
:environments, :protected_environments, :error_tracking,
:serverless, :clusters, :audit_events)
end
# rubocop: disable Cop/PutProjectRoutesUnderScope
......
......@@ -481,7 +481,7 @@ It is possible to display metrics charts within [GitLab Flavored Markdown](../..
NOTE: **Note:**
Requires [Kubernetes](prometheus_library/kubernetes.md) metrics.
To display a metric chart, include a link of the form `https://<root_url>/<project>/environments/<environment_id>/metrics`.
To display a metric chart, include a link of the form `https://<root_url>/<project>/-/environments/<environment_id>/metrics`.
A single chart may also be embedded. You can generate a link to the chart via the dropdown located on the right side of the chart:
......
......@@ -61,6 +61,25 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
resources :subscriptions, only: [:create, :destroy]
resources :licenses, only: [:index, :create, :update], controller: 'security/licenses'
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 of the /-/ scope.
......@@ -192,25 +211,6 @@ constraints(::Constraints::ProjectUrlConstrainer.new) do
resource :dependencies, only: [:show]
resource :licenses, only: [:show]
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]
# All new routes should go under /-/ scope.
# Look for scope '-' at the top of the file.
# rubocop: enable Cop/PutProjectRoutesUnderScope
......
......@@ -50,4 +50,16 @@ describe 'EE-specific project routing' do
expect(post('/gitlab/gitlabhq/-/settings/operations/reset_alerting_token')).to route_to('projects/settings/operations#reset_alerting_token', namespace_id: 'gitlab', project_id: 'gitlabhq')
end
end
describe Projects::ProtectedEnvironmentsController, 'routing' do
describe 'legacy routing' do
it_behaves_like 'redirecting a legacy project path', "/gitlab/gitlabhq/protected_environments", "/gitlab/gitlabhq/-/protected_environments"
end
end
describe Projects::AuditEventsController, 'routing' do
describe 'legacy routing' do
it_behaves_like 'redirecting a legacy project path', "/gitlab/gitlabhq/audit_events", "/gitlab/gitlabhq/-/audit_events"
end
end
end
......@@ -11,7 +11,7 @@ describe 'environments routing' do
end
let(:environments_route) do
"#{project.full_path}/environments/"
"#{project.full_path}/-/environments/"
end
describe 'routing environment folders' do
......@@ -38,7 +38,7 @@ describe 'environments routing' do
end
def get_folder(folder)
get("#{project.full_path}/environments/folders/#{folder}")
get("#{project.full_path}/-/environments/folders/#{folder}")
end
def folder_action(**opts)
......
......@@ -794,4 +794,28 @@ describe 'project routing' do
expect(post('/gitlab/gitlabhq/usage_ping/web_ide_clientside_preview')).to route_to('projects/usage_ping#web_ide_clientside_preview', namespace_id: 'gitlab', project_id: 'gitlabhq')
end
end
describe Projects::EnvironmentsController, 'routing' do
describe 'legacy routing' do
it_behaves_like 'redirecting a legacy project path', "/gitlab/gitlabhq/environments", "/gitlab/gitlabhq/-/environments"
end
end
describe Projects::ClustersController, 'routing' do
describe 'legacy routing' do
it_behaves_like 'redirecting a legacy project path', "/gitlab/gitlabhq/clusters", "/gitlab/gitlabhq/-/clusters"
end
end
describe Projects::ErrorTrackingController, 'routing' do
describe 'legacy routing' do
it_behaves_like 'redirecting a legacy project path', "/gitlab/gitlabhq/error_tracking", "/gitlab/gitlabhq/-/error_tracking"
end
end
describe Projects::Serverless, 'routing' do
describe 'legacy routing' do
it_behaves_like 'redirecting a legacy project path', "/gitlab/gitlabhq/serverless", "/gitlab/gitlabhq/-/serverless"
end
end
end
......@@ -24,7 +24,7 @@ describe ClusterBasicEntity do
it 'exposes the cluster details' do
expect(subject[:name]).to eq('the-cluster')
expect(subject[:path]).to eq("/#{project.full_path}/clusters/#{cluster.id}")
expect(subject[:path]).to eq("/#{project.full_path}/-/clusters/#{cluster.id}")
end
context 'when the user does not have permission to view the cluster' do
......
......@@ -73,7 +73,7 @@ describe EnvironmentStatusEntity do
it 'returns metrics url' do
expect(subject[:metrics_url])
.to eq("/#{project.full_path}/environments/#{environment.id}/deployments/#{deployment.iid}/metrics")
.to eq("/#{project.full_path}/-/environments/#{environment.id}/deployments/#{deployment.iid}/metrics")
end
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