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
5ab12ad0
Commit
5ab12ad0
authored
Jan 13, 2016
by
Gabriel Mazetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Gitlab Geo initial node discovery
parent
bd064da6
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
63 additions
and
0 deletions
+63
-0
app/models/geo_node.rb
app/models/geo_node.rb
+17
-0
app/validators/hostname_validator.rb
app/validators/hostname_validator.rb
+20
-0
db/migrate/20160112174440_create_geo_nodes.rb
db/migrate/20160112174440_create_geo_nodes.rb
+9
-0
db/schema.rb
db/schema.rb
+6
-0
lib/gitlab/geo.rb
lib/gitlab/geo.rb
+11
-0
No files found.
app/models/geo_node.rb
0 → 100644
View file @
5ab12ad0
# == Schema Information
#
# Table name: geo_nodes
#
# id :integer not null, primary key
# host :string
# relative_url_root :string
# primary :boolean
#
class
GeoNode
<
ActiveRecord
::
Base
default_value_for
:primary
,
false
default_value_for
:relative_url_root
,
''
validates
:host
,
hostname:
true
,
presence:
true
,
uniqueness:
{
case_sensitive:
false
}
validates
:primary
,
uniqueness:
{
message:
'primary node already exists'
},
if: :primary
end
app/validators/hostname_validator.rb
0 → 100644
View file @
5ab12ad0
# HostnameValidator
#
# Custom validator for Hostnames.
#
# This is similar to an URI validator, but will make sure no schema or
# path is present, only the domain part.
#
class
HostnameValidator
<
ActiveModel
::
EachValidator
def
validate_each
(
record
,
attribute
,
value
)
unless
valid_hostname?
(
value
)
record
.
errors
.
add
(
attribute
,
'must be a valid host'
)
end
end
private
def
valid_hostname?
(
value
)
URI
.
parse
(
"fake://
#{
value
}
"
).
hostname
==
value
end
end
db/migrate/20160112174440_create_geo_nodes.rb
0 → 100644
View file @
5ab12ad0
class
CreateGeoNodes
<
ActiveRecord
::
Migration
def
change
create_table
:geo_nodes
do
|
t
|
t
.
string
:host
t
.
string
:relative_url_root
t
.
boolean
:primary
end
end
end
db/schema.rb
View file @
5ab12ad0
...
@@ -400,6 +400,12 @@ ActiveRecord::Schema.define(version: 20160119170055) do
...
@@ -400,6 +400,12 @@ ActiveRecord::Schema.define(version: 20160119170055) do
add_index
"forked_project_links"
,
[
"forked_to_project_id"
],
name:
"index_forked_project_links_on_forked_to_project_id"
,
unique:
true
,
using: :btree
add_index
"forked_project_links"
,
[
"forked_to_project_id"
],
name:
"index_forked_project_links_on_forked_to_project_id"
,
unique:
true
,
using: :btree
create_table
"geo_nodes"
,
force: :cascade
do
|
t
|
t
.
string
"host"
t
.
string
"relative_url_root"
t
.
boolean
"primary"
end
create_table
"git_hooks"
,
force: :cascade
do
|
t
|
create_table
"git_hooks"
,
force: :cascade
do
|
t
|
t
.
string
"force_push_regex"
t
.
string
"force_push_regex"
t
.
string
"delete_branch_regex"
t
.
string
"delete_branch_regex"
...
...
lib/gitlab/geo.rb
0 → 100644
View file @
5ab12ad0
module
Gitlab
module
Geo
def
self
.
enabled?
GeoNode
.
exists?
end
def
self
.
current_node
GeoNode
.
find_by
(
host:
Gitlab
.
config
.
gitlab
.
host
,
relative_url_root:
Gitlab
.
config
.
gitlab
.
relative_url_root
)
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