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
ce6431f6
Commit
ce6431f6
authored
Apr 22, 2016
by
Gabriel Mazetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Requires a specific license Add-On to use Geo.
parent
8dce2158
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
1 deletion
+35
-1
app/controllers/admin/geo_nodes_controller.rb
app/controllers/admin/geo_nodes_controller.rb
+9
-0
lib/gitlab/geo.rb
lib/gitlab/geo.rb
+4
-0
lib/gitlab/git_access.rb
lib/gitlab/git_access.rb
+5
-1
spec/lib/gitlab/geo_spec.rb
spec/lib/gitlab/geo_spec.rb
+17
-0
No files found.
app/controllers/admin/geo_nodes_controller.rb
View file @
ce6431f6
class
Admin::GeoNodesController
<
Admin
::
ApplicationController
before_action
:check_license
def
index
@nodes
=
GeoNode
.
all
@node
=
GeoNode
.
new
...
...
@@ -41,4 +43,11 @@ class Admin::GeoNodesController < Admin::ApplicationController
def
geo_node_params
params
.
require
(
:geo_node
).
permit
(
:url
,
:primary
,
geo_node_key_attributes:
[
:key
])
end
def
check_license
unless
Gitlab
::
Geo
.
license_allows?
flash
[
:alert
]
=
'You need a diferent license to enable Geo replication'
redirect_to
admin_license_path
end
end
end
lib/gitlab/geo.rb
View file @
ce6431f6
...
...
@@ -22,6 +22,10 @@ module Gitlab
RequestStore
.
store
[
:geo_node_enabled
]
||=
GeoNode
.
exists?
end
def
self
.
license_allows?
::
License
.
current
&&
::
License
.
current
.
add_on?
(
'GitLab_Geo'
)
end
def
self
.
primary?
RequestStore
.
store
[
:geo_node_primary?
]
||=
self
.
enabled?
&&
self
.
current_node
&&
self
.
current_node
.
primary?
end
...
...
lib/gitlab/git_access.rb
View file @
ce6431f6
...
...
@@ -70,6 +70,10 @@ module Gitlab
return
build_status_object
(
false
,
'The project you were looking for could not be found.'
)
end
if
Gitlab
::
Geo
.
secondary?
&&
!
Gitlab
::
Geo
.
license_allows?
return
build_status_object
(
false
,
'Your current license does not have GitLab Geo add-on enabled.'
)
end
case
cmd
when
*
DOWNLOAD_COMMANDS
download_access_check
...
...
@@ -94,7 +98,7 @@ module Gitlab
def
push_access_check
(
changes
)
if
Gitlab
::
Geo
.
enabled?
&&
Gitlab
::
Geo
.
secondary?
if
Gitlab
::
Geo
.
secondary?
return
build_status_object
(
false
,
"You can't push code on a secondary GitLab Geo node."
)
end
...
...
spec/lib/gitlab/geo_spec.rb
View file @
ce6431f6
...
...
@@ -68,4 +68,21 @@ describe Gitlab::Geo, lib: true do
expect
(
described_class
.
geo_node?
(
host:
'inexistent'
,
port:
1234
)).
to
be_falsey
end
end
describe
'license_allows?'
do
it
'returns true if license has Geo addon'
do
allow_any_instance_of
(
License
).
to
receive
(
:add_on?
).
with
(
'GitLab_Geo'
)
{
true
}
expect
(
described_class
.
license_allows?
).
to
be_truthy
end
it
'returns false if license doesnt have Geo addon'
do
allow_any_instance_of
(
License
).
to
receive
(
:add_on?
).
with
(
'GitLab_Geo'
)
{
false
}
expect
(
described_class
.
license_allows?
).
to
be_falsey
end
it
'returns false if no license is present'
do
allow
(
License
).
to
receive
(
:current
)
{
nil
}
expect
(
described_class
.
license_allows?
).
to
be_falsey
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