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
a2c6dacc
Commit
a2c6dacc
authored
Mar 04, 2016
by
Gabriel Mazetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rename Geo node term: readonly -> secondary
parent
20a9335c
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
20 additions
and
20 deletions
+20
-20
app/controllers/application_controller.rb
app/controllers/application_controller.rb
+1
-1
app/controllers/sessions_controller.rb
app/controllers/sessions_controller.rb
+1
-1
lib/gitlab/geo.rb
lib/gitlab/geo.rb
+1
-1
lib/gitlab/git_access.rb
lib/gitlab/git_access.rb
+3
-3
lib/gitlab/git_access_wiki.rb
lib/gitlab/git_access_wiki.rb
+2
-2
lib/gitlab/middleware/readonly_geo.rb
lib/gitlab/middleware/readonly_geo.rb
+2
-2
spec/lib/gitlab/geo_spec.rb
spec/lib/gitlab/geo_spec.rb
+2
-2
spec/lib/gitlab/git_access_spec.rb
spec/lib/gitlab/git_access_spec.rb
+4
-4
spec/lib/gitlab/git_access_wiki_spec.rb
spec/lib/gitlab/git_access_wiki_spec.rb
+2
-2
spec/lib/gitlab/middleware/readonly_geo_spec.rb
spec/lib/gitlab/middleware/readonly_geo_spec.rb
+2
-2
No files found.
app/controllers/application_controller.rb
View file @
a2c6dacc
...
...
@@ -107,7 +107,7 @@ class ApplicationController < ActionController::Base
end
def
after_sign_out_path_for
(
resource
)
if
Gitlab
::
Geo
.
readonl
y?
if
Gitlab
::
Geo
.
secondar
y?
Gitlab
::
Geo
.
primary_node
.
url
else
current_application_settings
.
after_sign_out_path
||
new_user_session_path
...
...
app/controllers/sessions_controller.rb
View file @
a2c6dacc
...
...
@@ -91,7 +91,7 @@ class SessionsController < Devise::SessionsController
end
def
gitlab_geo_login
if
!
signed_in?
&&
Gitlab
::
Geo
.
enabled?
&&
Gitlab
::
Geo
.
readonl
y?
if
!
signed_in?
&&
Gitlab
::
Geo
.
enabled?
&&
Gitlab
::
Geo
.
secondar
y?
# share full url with primary node by shared session
user_return_to
=
URI
.
join
(
root_url
,
session
[
:user_return_to
]).
to_s
session
[
:geo_node_return_to
]
=
@redirect_to
||
user_return_to
...
...
lib/gitlab/geo.rb
View file @
a2c6dacc
...
...
@@ -24,7 +24,7 @@ module Gitlab
RequestStore
.
store
[
:geo_node_primary?
]
||=
self
.
enabled?
&&
self
.
current_node
&&
self
.
current_node
.
primary?
end
def
self
.
readonl
y?
def
self
.
secondar
y?
RequestStore
.
store
[
:geo_node_readonly?
]
||=
self
.
enabled?
&&
self
.
current_node
&&
!
self
.
current_node
.
primary?
end
...
...
lib/gitlab/git_access.rb
View file @
a2c6dacc
...
...
@@ -94,7 +94,7 @@ module Gitlab
def
push_access_check
(
changes
)
if
Gitlab
::
Geo
.
enabled?
&&
Gitlab
::
Geo
.
readonl
y?
if
Gitlab
::
Geo
.
enabled?
&&
Gitlab
::
Geo
.
secondar
y?
return
build_status_object
(
false
,
"You can't push code on a secondary Gitlab Geo node."
)
end
...
...
@@ -336,8 +336,8 @@ module Gitlab
return
build_status_object
(
false
,
"Repository does not exist"
)
end
if
Gitlab
::
Geo
.
enabled?
&&
Gitlab
::
Geo
.
readonl
y?
return
build_status_object
(
false
,
"You can't use git-annex with
Gitlab Geo secondary
node."
)
if
Gitlab
::
Geo
.
enabled?
&&
Gitlab
::
Geo
.
secondar
y?
return
build_status_object
(
false
,
"You can't use git-annex with
a secondary Gitlab Geo
node."
)
end
if
user
.
can?
(
:push_code
,
project
)
...
...
lib/gitlab/git_access_wiki.rb
View file @
a2c6dacc
module
Gitlab
class
GitAccessWiki
<
GitAccess
def
change_access_check
(
change
)
if
Gitlab
::
Geo
.
enabled?
&&
Gitlab
::
Geo
.
readonl
y?
build_status_object
(
false
,
"You can't push code
on
a secondary Gitlab Geo node."
)
if
Gitlab
::
Geo
.
enabled?
&&
Gitlab
::
Geo
.
secondar
y?
build_status_object
(
false
,
"You can't push code
to
a secondary Gitlab Geo node."
)
elsif
user
.
can?
(
:create_wiki
,
project
)
build_status_object
(
true
)
else
...
...
lib/gitlab/middleware/readonly_geo.rb
View file @
a2c6dacc
...
...
@@ -10,10 +10,10 @@ module Gitlab
def
call
(
env
)
@env
=
env
if
disallowed_request?
&&
Gitlab
::
Geo
.
readonl
y?
if
disallowed_request?
&&
Gitlab
::
Geo
.
secondar
y?
Rails
.
logger
.
debug
(
'Gitlab Geo: preventing possible non readonly operation'
)
rack_flash
.
alert
=
'You cannot do writing operations on a
readonl
y Gitlab Geo instance'
rack_flash
.
alert
=
'You cannot do writing operations on a
secondar
y Gitlab Geo instance'
rack_session
[
'flash'
]
=
rack_flash
.
to_session_value
return
[
301
,
{
'Location'
=>
last_visited_url
},
[]]
...
...
spec/lib/gitlab/geo_spec.rb
View file @
a2c6dacc
...
...
@@ -45,7 +45,7 @@ describe Gitlab::Geo, lib: true do
it
'returns true'
do
allow
(
described_class
).
to
receive
(
:current_node
)
{
secondary_node
}
expect
(
described_class
.
readonl
y?
).
to
be_truthy
expect
(
described_class
.
secondar
y?
).
to
be_truthy
end
end
...
...
@@ -54,7 +54,7 @@ describe Gitlab::Geo, lib: true do
it
'returns false when '
do
allow
(
described_class
).
to
receive
(
:current_node
)
{
primary_node
}
expect
(
described_class
.
readonl
y?
).
to
be_falsey
expect
(
described_class
.
secondar
y?
).
to
be_falsey
end
end
end
...
...
spec/lib/gitlab/git_access_spec.rb
View file @
a2c6dacc
...
...
@@ -260,10 +260,10 @@ describe Gitlab::GitAccess, lib: true do
end
end
context
"when in a
readonl
y gitlab geo node"
do
context
"when in a
secondar
y gitlab geo node"
do
before
do
allow
(
Gitlab
::
Geo
).
to
receive
(
:enabled?
)
{
true
}
allow
(
Gitlab
::
Geo
).
to
receive
(
:
readonl
y?
)
{
true
}
allow
(
Gitlab
::
Geo
).
to
receive
(
:
secondar
y?
)
{
true
}
end
permissions_matrix
.
keys
.
each
do
|
role
|
...
...
@@ -285,11 +285,11 @@ describe Gitlab::GitAccess, lib: true do
context
"when using git annex"
do
before
{
project
.
team
<<
[
user
,
:master
]
}
describe
'and gitlab geo is enabled in a
readonl
y node'
do
describe
'and gitlab geo is enabled in a
secondar
y node'
do
before
do
allow
(
Gitlab
.
config
.
gitlab_shell
).
to
receive
(
:git_annex_enabled
).
and_return
(
true
)
allow
(
Gitlab
::
Geo
).
to
receive
(
:enabled?
)
{
true
}
allow
(
Gitlab
::
Geo
).
to
receive
(
:
readonl
y?
)
{
true
}
allow
(
Gitlab
::
Geo
).
to
receive
(
:
secondar
y?
)
{
true
}
end
it
{
expect
(
access
.
push_access_check
(
git_annex_changes
)).
not_to
be_allowed
}
...
...
spec/lib/gitlab/git_access_wiki_spec.rb
View file @
a2c6dacc
...
...
@@ -17,10 +17,10 @@ describe Gitlab::GitAccessWiki, lib: true do
it
{
expect
(
subject
.
allowed?
).
to
be_truthy
}
context
'when in a
readonl
y gitlab geo node'
do
context
'when in a
secondar
y gitlab geo node'
do
before
do
allow
(
Gitlab
::
Geo
).
to
receive
(
:enabled?
)
{
true
}
allow
(
Gitlab
::
Geo
).
to
receive
(
:
readonl
y?
)
{
true
}
allow
(
Gitlab
::
Geo
).
to
receive
(
:
secondar
y?
)
{
true
}
end
it
{
expect
(
subject
.
allowed?
).
to
be_falsey
}
...
...
spec/lib/gitlab/middleware/readonly_geo_spec.rb
View file @
a2c6dacc
...
...
@@ -31,8 +31,8 @@ describe Gitlab::Middleware::ReadonlyGeo, lib: true do
let
(
:fake_app
)
{
lambda
{
|
env
|
[
200
,
{
'Content-Type'
=>
'text/plain'
},
[
'OK'
]]
}
}
let
(
:request
)
{
@request
||=
Rack
::
MockRequest
.
new
(
rack_stack
)
}
context
'when in
Gitlab Geo readonly
node'
do
before
(
:each
)
{
allow
(
Gitlab
::
Geo
).
to
receive
(
:
readonl
y?
)
{
true
}
}
context
'when in
secondary Gitlab Geo
node'
do
before
(
:each
)
{
allow
(
Gitlab
::
Geo
).
to
receive
(
:
secondar
y?
)
{
true
}
}
it
'expects PATCH requests to be disallowed'
do
response
=
request
.
patch
(
'/test_request'
)
...
...
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