Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
e452dce3
Commit
e452dce3
authored
Oct 15, 2018
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Put EE routes in EE files under EE directories
parent
e8df1bfe
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
179 additions
and
128 deletions
+179
-128
.rubocop.yml
.rubocop.yml
+1
-0
config/initializers/routing_draw.rb
config/initializers/routing_draw.rb
+2
-6
config/routes/admin.rb
config/routes/admin.rb
+0
-32
config/routes/group.rb
config/routes/group.rb
+3
-84
doc/development/ee_features.md
doc/development/ee_features.md
+15
-6
ee/config/routes/admin.rb
ee/config/routes/admin.rb
+41
-0
ee/config/routes/group.rb
ee/config/routes/group.rb
+96
-0
lib/gitlab/patch/draw_route.rb
lib/gitlab/patch/draw_route.rb
+21
-0
No files found.
.rubocop.yml
View file @
e452dce3
...
@@ -76,6 +76,7 @@ Naming/FileName:
...
@@ -76,6 +76,7 @@ Naming/FileName:
-
'
qa/qa/specs/**/*'
-
'
qa/qa/specs/**/*'
-
'
qa/bin/*'
-
'
qa/bin/*'
-
'
config/**/*'
-
'
config/**/*'
-
'
ee/config/**/*'
-
'
lib/generators/**/*'
-
'
lib/generators/**/*'
-
'
locale/unfound_translations.rb'
-
'
locale/unfound_translations.rb'
-
'
ee/locale/unfound_translations.rb'
-
'
ee/locale/unfound_translations.rb'
...
...
config/initializers/routing_draw.rb
View file @
e452dce3
# Adds draw method into Rails routing
# Adds draw method into Rails routing
# It allows us to keep routing splitted into files
# It allows us to keep routing split into files
class
ActionDispatch::Routing::Mapper
ActionDispatch
::
Routing
::
Mapper
.
prepend
Gitlab
::
Patch
::
DrawRoute
def
draw
(
routes_name
)
instance_eval
(
File
.
read
(
Rails
.
root
.
join
(
"config/routes/
#{
routes_name
}
.rb"
)))
end
end
config/routes/admin.rb
View file @
e452dce3
...
@@ -16,17 +16,11 @@ namespace :admin do
...
@@ -16,17 +16,11 @@ namespace :admin do
put
:unlock
put
:unlock
put
:confirm
put
:confirm
post
:impersonate
post
:impersonate
post
:reset_runners_minutes
patch
:disable_two_factor
patch
:disable_two_factor
delete
'remove/:email_id'
,
action:
'remove_email'
,
as:
'remove_email'
delete
'remove/:email_id'
,
action:
'remove_email'
,
as:
'remove_email'
end
end
end
end
## EE-specific
resource
:push_rule
,
only:
[
:show
,
:update
]
get
:instance_review
,
to:
'instance_review#index'
## EE-specific
resource
:impersonation
,
only: :destroy
resource
:impersonation
,
only: :destroy
resources
:abuse_reports
,
only:
[
:index
,
:destroy
]
resources
:abuse_reports
,
only:
[
:index
,
:destroy
]
...
@@ -48,7 +42,6 @@ namespace :admin do
...
@@ -48,7 +42,6 @@ namespace :admin do
scope
(
as: :group
)
do
scope
(
as: :group
)
do
put
:members_update
put
:members_update
post
:reset_runners_minutes
get
:edit
,
action: :edit
get
:edit
,
action: :edit
get
'/'
,
action: :show
get
'/'
,
action: :show
patch
'/'
,
action: :update
patch
'/'
,
action: :update
...
@@ -79,11 +72,6 @@ namespace :admin do
...
@@ -79,11 +72,6 @@ namespace :admin do
resource
:health_check
,
controller:
'health_check'
,
only:
[
:show
]
resource
:health_check
,
controller:
'health_check'
,
only:
[
:show
]
resource
:background_jobs
,
controller:
'background_jobs'
,
only:
[
:show
]
resource
:background_jobs
,
controller:
'background_jobs'
,
only:
[
:show
]
## EE-specific
resource
:email
,
only:
[
:show
,
:create
]
resources
:audit_logs
,
controller:
'audit_logs'
,
only:
[
:index
]
## EE-specific
resource
:system_info
,
controller:
'system_info'
,
only:
[
:show
]
resource
:system_info
,
controller:
'system_info'
,
only:
[
:show
]
resources
:requests_profiles
,
only:
[
:index
,
:show
],
param: :name
,
constraints:
{
name:
/.+\.html/
}
resources
:requests_profiles
,
only:
[
:index
,
:show
],
param: :name
,
constraints:
{
name:
/.+\.html/
}
...
@@ -125,26 +113,6 @@ namespace :admin do
...
@@ -125,26 +113,6 @@ namespace :admin do
get
:integrations
,
:repository
,
:templates
,
:ci_cd
,
:reporting
,
:metrics_and_profiling
,
:network
,
:geo
,
:preferences
get
:integrations
,
:repository
,
:templates
,
:ci_cd
,
:reporting
,
:metrics_and_profiling
,
:network
,
:geo
,
:preferences
end
end
## EE-specific
resource
:license
,
only:
[
:show
,
:new
,
:create
,
:destroy
]
do
get
:download
,
on: :member
end
namespace
:geo
do
resources
:nodes
,
only:
[
:index
,
:create
,
:new
,
:edit
,
:update
]
resources
:projects
,
only:
[
:index
,
:destroy
]
do
member
do
post
:recheck
post
:resync
post
:force_redownload
end
end
end
get
'/dashboard/stats'
,
to:
'dashboard#stats'
## EE-specific
resources
:labels
resources
:labels
resources
:runners
,
only:
[
:index
,
:show
,
:update
,
:destroy
]
do
resources
:runners
,
only:
[
:index
,
:show
,
:update
,
:destroy
]
do
...
...
config/routes/group.rb
View file @
e452dce3
# frozen_string_literal: true
resources
:groups
,
only:
[
:index
,
:new
,
:create
]
do
resources
:groups
,
only:
[
:index
,
:new
,
:create
]
do
post
:preview_markdown
post
:preview_markdown
end
end
...
@@ -13,7 +15,6 @@ constraints(::Constraints::GroupUrlConstrainer.new) do
...
@@ -13,7 +15,6 @@ constraints(::Constraints::GroupUrlConstrainer.new) do
get
:merge_requests
,
as: :merge_requests_group
get
:merge_requests
,
as: :merge_requests_group
get
:projects
,
as: :projects_group
get
:projects
,
as: :projects_group
get
:activity
,
as: :activity_group
get
:activity
,
as: :activity_group
get
:subgroups
,
as: :subgroups_group
## EE-specific
put
:transfer
,
as: :transfer_group
put
:transfer
,
as: :transfer_group
# TODO: Remove as part of refactor in https://gitlab.com/gitlab-org/gitlab-ce/issues/49693
# TODO: Remove as part of refactor in https://gitlab.com/gitlab-org/gitlab-ce/issues/49693
get
'shared'
,
action: :show
,
as: :group_shared
get
'shared'
,
action: :show
,
as: :group_shared
...
@@ -55,7 +56,6 @@ constraints(::Constraints::GroupUrlConstrainer.new) do
...
@@ -55,7 +56,6 @@ constraints(::Constraints::GroupUrlConstrainer.new) do
resources
:group_members
,
only:
[
:index
,
:create
,
:update
,
:destroy
],
concerns: :access_requestable
do
resources
:group_members
,
only:
[
:index
,
:create
,
:update
,
:destroy
],
concerns: :access_requestable
do
post
:resend_invite
,
on: :member
post
:resend_invite
,
on: :member
delete
:leave
,
on: :collection
delete
:leave
,
on: :collection
patch
:override
,
on: :member
## EE-specific
end
end
resources
:uploads
,
only:
[
:create
]
do
resources
:uploads
,
only:
[
:create
]
do
...
@@ -65,71 +65,7 @@ constraints(::Constraints::GroupUrlConstrainer.new) do
...
@@ -65,71 +65,7 @@ constraints(::Constraints::GroupUrlConstrainer.new) do
end
end
end
end
## EE-specific
resources
:boards
,
only:
[
:index
,
:show
]
resource
:analytics
,
only:
[
:show
]
resource
:ldap
,
only:
[]
do
member
do
put
:sync
end
end
resources
:ldap_group_links
,
only:
[
:index
,
:create
,
:destroy
]
# EE-specific start
namespace
:security
do
resource
:dashboard
,
only:
[
:show
],
controller: :dashboard
resources
:vulnerabilities
,
only:
[
:index
],
controller: :vulnerabilities
do
collection
do
get
:summary
end
end
end
# EE-specific end
## EE-specific
resource
:saml_providers
,
path:
'saml'
,
only:
[
:show
,
:create
,
:update
]
do
post
:callback
,
to:
'omniauth_callbacks#group_saml'
get
:sso
,
to:
'sso#saml'
end
resource
:notification_setting
,
only:
[
:update
]
resources
:audit_events
,
only:
[
:index
]
resources
:pipeline_quota
,
only:
[
:index
]
resources
:hooks
,
only:
[
:index
,
:create
,
:destroy
],
constraints:
{
id:
/\d+/
}
do
member
do
post
:test
end
end
resources
:autocomplete_sources
,
only:
[]
do
collection
do
get
'members'
get
'labels'
get
'epics'
get
'commands'
end
end
resources
:billings
,
only:
[
:index
]
resources
:epics
,
concerns: :awardable
,
constraints:
{
id:
/\d+/
}
do
member
do
get
:discussions
,
format: :json
get
:realtime_changes
post
:toggle_subscription
end
resources
:epic_issues
,
only:
[
:index
,
:create
,
:destroy
,
:update
],
as:
'issues'
,
path:
'issues'
scope
module: :epics
do
resources
:notes
,
only:
[
:index
,
:create
,
:destroy
,
:update
],
concerns: :awardable
,
constraints:
{
id:
/\d+/
}
end
end
resources
:todos
,
only:
[
:create
]
# On CE only index and show are needed
resources
:boards
,
only:
[
:index
,
:show
,
:create
,
:update
,
:destroy
]
resources
:runners
,
only:
[
:index
,
:edit
,
:update
,
:destroy
,
:show
]
do
resources
:runners
,
only:
[
:index
,
:edit
,
:update
,
:destroy
,
:show
]
do
member
do
member
do
...
@@ -137,17 +73,6 @@ constraints(::Constraints::GroupUrlConstrainer.new) do
...
@@ -137,17 +73,6 @@ constraints(::Constraints::GroupUrlConstrainer.new) do
post
:pause
post
:pause
end
end
end
end
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
## EE-specific
resource
:roadmap
,
only:
[
:show
],
controller:
'roadmap'
end
end
scope
(
path:
'*id'
,
scope
(
path:
'*id'
,
...
@@ -166,11 +91,5 @@ constraints(::Constraints::GroupUrlConstrainer.new) do
...
@@ -166,11 +91,5 @@ constraints(::Constraints::GroupUrlConstrainer.new) do
Gitlab
::
Routing
.
redirect_legacy_paths
(
self
,
:labels
,
:milestones
,
:group_members
,
Gitlab
::
Routing
.
redirect_legacy_paths
(
self
,
:labels
,
:milestones
,
:group_members
,
:edit
,
:issues
,
:merge_requests
,
:projects
,
:edit
,
:issues
,
:merge_requests
,
:projects
,
:activity
)
:activity
)
## EE-specific
Gitlab
::
Routing
.
redirect_legacy_paths
(
self
,
:analytics
,
:ldap
,
:ldap_group_links
,
:notification_setting
,
:audit_events
,
:pipeline_quota
,
:hooks
,
:boards
)
## EE-specific
end
end
end
end
doc/development/ee_features.md
View file @
e452dce3
...
@@ -171,7 +171,7 @@ There are a few gotchas with it:
...
@@ -171,7 +171,7 @@ There are a few gotchas with it:
class Base
class Base
def execute
def execute
return unless enabled?
return unless enabled?
# ...
# ...
# ...
# ...
end
end
...
@@ -185,12 +185,12 @@ There are a few gotchas with it:
...
@@ -185,12 +185,12 @@ There are a few gotchas with it:
class Base
class Base
def execute
def execute
return unless enabled?
return unless enabled?
do_something
do_something
end
end
private
private
def do_something
def do_something
# ...
# ...
# ...
# ...
...
@@ -204,14 +204,14 @@ There are a few gotchas with it:
...
@@ -204,14 +204,14 @@ There are a few gotchas with it:
```ruby
```ruby
module EE::Base
module EE::Base
extend ::Gitlab::Utils::Override
extend ::Gitlab::Utils::Override
override :do_something
override :do_something
def do_something
def do_something
# Follow the above pattern to call super and extend it
# Follow the above pattern to call super and extend it
end
end
end
end
```
```
This would require updating CE first, or make sure this is back ported to CE.
This would require updating CE first, or make sure this is back ported to CE.
When prepending, place them in the
`ee/`
specific sub-directory, and
When prepending, place them in the
`ee/`
specific sub-directory, and
...
@@ -332,6 +332,15 @@ full implementation details.
...
@@ -332,6 +332,15 @@ full implementation details.
[
ce-mr-full-private
]:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/12373
[
ce-mr-full-private
]:
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/12373
[
ee-mr-full-private
]:
https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/2199
[
ee-mr-full-private
]:
https://gitlab.com/gitlab-org/gitlab-ee/merge_requests/2199
### Code in `config/routes`
When we add
`draw :admin`
in
`config/routes.rb`
, the application will also
load the file located in
`config/routes/admin.rb`
, and also
`ee/config/routes/admin.rb`
if the file exists.
So if we want to extend a particular route file, just add the same file
located in
`ee/config/routes`
.
### Code in `app/controllers/`
### Code in `app/controllers/`
In controllers, the most common type of conflict is with
`before_action`
that
In controllers, the most common type of conflict is with
`before_action`
that
...
...
ee/config/routes/admin.rb
0 → 100644
View file @
e452dce3
# frozen_string_literal: true
namespace
:admin
do
resources
:users
,
constraints:
{
id:
%r{[a-zA-Z./0-9_
\-
]+}
}
do
member
do
post
:reset_runners_minutes
end
end
scope
(
path:
'groups/*id'
,
controller: :groups
,
constraints:
{
id:
Gitlab
::
PathRegex
.
full_namespace_route_regex
,
format:
/(html|json|atom)/
})
do
scope
(
as: :group
)
do
post
:reset_runners_minutes
end
end
get
:instance_review
,
to:
'instance_review#index'
resource
:push_rule
,
only:
[
:show
,
:update
]
resource
:email
,
only:
[
:show
,
:create
]
resources
:audit_logs
,
controller:
'audit_logs'
,
only:
[
:index
]
resource
:license
,
only:
[
:show
,
:new
,
:create
,
:destroy
]
do
get
:download
,
on: :member
end
namespace
:geo
do
resources
:nodes
,
only:
[
:index
,
:create
,
:new
,
:edit
,
:update
]
resources
:projects
,
only:
[
:index
,
:destroy
]
do
member
do
post
:recheck
post
:resync
post
:force_redownload
end
end
end
get
'/dashboard/stats'
,
to:
'dashboard#stats'
end
ee/config/routes/group.rb
0 → 100644
View file @
e452dce3
# frozen_string_literal: true
constraints
(
::
Constraints
::
GroupUrlConstrainer
.
new
)
do
scope
(
path:
'groups/*id'
,
controller: :groups
,
constraints:
{
id:
Gitlab
::
PathRegex
.
full_namespace_route_regex
,
format:
/(html|json|atom|ics)/
})
do
scope
(
path:
'-'
)
do
get
:subgroups
,
as: :subgroups_group
end
end
scope
(
path:
'groups/*group_id/-'
,
module: :groups
,
as: :group
,
constraints:
{
group_id:
Gitlab
::
PathRegex
.
full_namespace_route_regex
})
do
resources
:group_members
,
only:
[],
concerns: :access_requestable
do
patch
:override
,
on: :member
end
resource
:analytics
,
only:
[
:show
]
resource
:ldap
,
only:
[]
do
member
do
put
:sync
end
end
resource
:notification_setting
,
only:
[
:update
]
resources
:ldap_group_links
,
only:
[
:index
,
:create
,
:destroy
]
resources
:audit_events
,
only:
[
:index
]
resources
:pipeline_quota
,
only:
[
:index
]
resources
:hooks
,
only:
[
:index
,
:create
,
:destroy
],
constraints:
{
id:
/\d+/
}
do
member
do
post
:test
end
end
resources
:autocomplete_sources
,
only:
[]
do
collection
do
get
'members'
get
'labels'
get
'epics'
get
'commands'
end
end
resources
:billings
,
only:
[
:index
]
resources
:epics
,
concerns: :awardable
,
constraints:
{
id:
/\d+/
}
do
member
do
get
:discussions
,
format: :json
get
:realtime_changes
post
:toggle_subscription
end
resources
:epic_issues
,
only:
[
:index
,
:create
,
:destroy
,
:update
],
as:
'issues'
,
path:
'issues'
scope
module: :epics
do
resources
:notes
,
only:
[
:index
,
:create
,
:destroy
,
:update
],
concerns: :awardable
,
constraints:
{
id:
/\d+/
}
end
end
resources
:todos
,
only:
[
:create
]
resources
:boards
,
only:
[
:create
,
:update
,
:destroy
]
namespace
:security
do
resource
:dashboard
,
only:
[
:show
],
controller: :dashboard
resources
:vulnerabilities
,
only:
[
:index
],
controller: :vulnerabilities
do
collection
do
get
:summary
end
end
end
resource
:saml_providers
,
path:
'saml'
,
only:
[
:show
,
:create
,
:update
]
do
post
:callback
,
to:
'omniauth_callbacks#group_saml'
get
:sso
,
to:
'sso#saml'
end
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
end
scope
(
path:
'groups/*group_id'
)
do
Gitlab
::
Routing
.
redirect_legacy_paths
(
self
,
:analytics
,
:ldap
,
:ldap_group_links
,
:notification_setting
,
:audit_events
,
:pipeline_quota
,
:hooks
,
:boards
)
end
end
lib/gitlab/patch/draw_route.rb
0 → 100644
View file @
e452dce3
# frozen_string_literal: true
# We're patching `ActionDispatch::Routing::Mapper` in
# config/initializers/routing_draw.rb
module
Gitlab
module
Patch
module
DrawRoute
def
draw
(
routes_name
)
instance_eval
(
File
.
read
(
Rails
.
root
.
join
(
"config/routes/
#{
routes_name
}
.rb"
)))
draw_ee
(
routes_name
)
end
def
draw_ee
(
routes_name
)
path
=
Rails
.
root
.
join
(
"ee/config/routes/
#{
routes_name
}
.rb"
)
instance_eval
(
File
.
read
(
path
))
if
File
.
exist?
(
path
)
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment