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
85083b38
Commit
85083b38
authored
Feb 21, 2016
by
Gabriel Mazetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added GeoNodeKey which will be used by readonly nodes to sync repos
parent
9dd9b607
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
89 additions
and
1 deletion
+89
-1
app/models/geo_node.rb
app/models/geo_node.rb
+2
-0
app/models/geo_node_key.rb
app/models/geo_node_key.rb
+30
-0
db/migrate/20160221013512_add_geo_node_key_to_geo_node.rb
db/migrate/20160221013512_add_geo_node_key_to_geo_node.rb
+7
-0
db/schema.rb
db/schema.rb
+2
-0
lib/gitlab/git_access.rb
lib/gitlab/git_access.rb
+9
-1
spec/factories.rb
spec/factories.rb
+3
-0
spec/lib/gitlab/git_access_spec.rb
spec/lib/gitlab/git_access_spec.rb
+11
-0
spec/models/geo_node_key_spec.rb
spec/models/geo_node_key_spec.rb
+25
-0
No files found.
app/models/geo_node.rb
View file @
85083b38
...
...
@@ -11,6 +11,8 @@
#
class
GeoNode
<
ActiveRecord
::
Base
belongs_to
:geo_node_key
default_value_for
:schema
,
'http'
default_value_for
:port
,
80
default_value_for
:relative_url_root
,
''
...
...
app/models/geo_node_key.rb
0 → 100644
View file @
85083b38
# == Schema Information
#
# Table name: keys
#
# id :integer not null, primary key
# user_id :integer
# created_at :datetime
# updated_at :datetime
# key :text
# title :string(255)
# type :string(255)
# fingerprint :string(255)
# public :boolean default(FALSE), not null
#
class
GeoNodeKey
<
Key
has_many
:geo_nodes
def
orphaned?
self
.
geo_nodes
.
length
==
0
end
def
almost_orphaned?
self
.
geo_nodes
.
length
==
1
end
def
destroyed_when_orphaned?
true
end
end
db/migrate/20160221013512_add_geo_node_key_to_geo_node.rb
0 → 100644
View file @
85083b38
class
AddGeoNodeKeyToGeoNode
<
ActiveRecord
::
Migration
def
change
change_table
:geo_nodes
do
|
t
|
t
.
belongs_to
:geo_node_key
,
index:
true
end
end
end
db/schema.rb
View file @
85083b38
...
...
@@ -413,8 +413,10 @@ ActiveRecord::Schema.define(version: 20160302141317) do
t
.
integer
"port"
t
.
string
"relative_url_root"
t
.
boolean
"primary"
t
.
integer
"geo_node_key_id"
end
add_index
"geo_nodes"
,
[
"geo_node_key_id"
],
name:
"index_geo_nodes_on_geo_node_key_id"
,
using: :btree
add_index
"geo_nodes"
,
[
"host"
],
name:
"index_geo_nodes_on_host"
,
using: :btree
add_index
"geo_nodes"
,
[
"primary"
],
name:
"index_geo_nodes_on_primary"
,
using: :btree
...
...
lib/gitlab/git_access.rb
View file @
85083b38
...
...
@@ -20,6 +20,8 @@ module Gitlab
actor
when
DeployKey
nil
when
GeoNodeKey
nil
when
Key
actor
.
user
end
...
...
@@ -29,6 +31,10 @@ module Gitlab
actor
if
actor
.
is_a?
(
DeployKey
)
end
def
geo_node_key
actor
if
actor
.
is_a?
(
GeoNodeKey
)
end
def
can_push_to_branch?
(
ref
)
return
false
unless
user
...
...
@@ -44,6 +50,8 @@ module Gitlab
user
.
can?
(
:read_project
,
project
)
elsif
deploy_key
deploy_key
.
projects
.
include?
(
project
)
elsif
geo_node_key
true
else
false
end
...
...
@@ -77,7 +85,7 @@ module Gitlab
def
download_access_check
if
user
user_download_access_check
elsif
deploy_key
elsif
deploy_key
||
geo_node_key
build_status_object
(
true
)
else
raise
'Wrong actor'
...
...
spec/factories.rb
View file @
85083b38
...
...
@@ -115,6 +115,9 @@ FactoryGirl.define do
factory
:deploy_key
,
class:
'DeployKey'
do
end
factory
:geo_node_key
,
class:
'GeoNodeKey'
do
end
factory
:personal_key
do
user
end
...
...
spec/lib/gitlab/git_access_spec.rb
View file @
85083b38
...
...
@@ -125,6 +125,17 @@ describe Gitlab::GitAccess, lib: true do
it
{
expect
(
subject
.
allowed?
).
to
be_truthy
}
end
end
describe
'geo node key permissions'
do
let
(
:key
)
{
build
(
:geo_node_key
)
}
let
(
:actor
)
{
key
}
context
'pull code'
do
subject
{
access
.
download_access_check
}
it
{
expect
(
subject
.
allowed?
).
to
be_truthy
}
end
end
end
describe
'push_access_check'
do
...
...
spec/models/geo_node_key_spec.rb
0 → 100644
View file @
85083b38
# == Schema Information
#
# Table name: keys
#
# id :integer not null, primary key
# user_id :integer
# created_at :datetime
# updated_at :datetime
# key :text
# title :string(255)
# type :string(255)
# fingerprint :string(255)
# public :boolean default(FALSE), not null
#
require
'spec_helper'
describe
GeoNodeKey
,
models:
true
do
let
(
:geo_node
)
{
create
(
:geo_node
)
}
let
(
:geo_node_key
)
{
create
(
:geo_node_key
,
geo_nodes:
[
geo_node
])
}
describe
'Associations'
do
it
{
is_expected
.
to
have_many
(
:geo_nodes
)
}
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