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
7ad4d842
Commit
7ad4d842
authored
Apr 14, 2016
by
Gabriel Mazetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Linked GeoNode with auto generated system hook.
parent
b39935f7
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
9 deletions
+18
-9
app/models/geo_node.rb
app/models/geo_node.rb
+9
-2
db/migrate/20160414032323_add_token_to_geo_node.rb
db/migrate/20160414032323_add_token_to_geo_node.rb
+0
-6
db/migrate/20160414064845_add_system_hook_to_geo_node.rb
db/migrate/20160414064845_add_system_hook_to_geo_node.rb
+7
-0
db/schema.rb
db/schema.rb
+2
-1
No files found.
app/models/geo_node.rb
View file @
7ad4d842
...
...
@@ -13,6 +13,7 @@
class
GeoNode
<
ActiveRecord
::
Base
belongs_to
:geo_node_key
,
dependent: :destroy
belongs_to
:oauth_application
,
class_name:
'Doorkeeper::Application'
,
dependent: :destroy
belongs_to
:system_hook
,
dependent: :destroy
default_values
schema:
'http'
,
host:
lambda
{
Gitlab
.
config
.
gitlab
.
host
},
...
...
@@ -61,8 +62,8 @@ class GeoNode < ActiveRecord::Base
URI
.
join
(
uri
,
"
#{
uri
.
path
}
/"
,
"api/
#{
API
::
API
.
version
}
/geo/refresh_wikis"
).
to_s
end
def
notify_key
_url
URI
.
join
(
uri
,
"
#{
uri
.
path
}
/"
,
"api/
#{
API
::
API
.
version
}
/geo/re
fresh_key
"
).
to_s
def
geo_events
_url
URI
.
join
(
uri
,
"
#{
uri
.
path
}
/"
,
"api/
#{
API
::
API
.
version
}
/geo/re
ceive_events
"
).
to_s
end
def
oauth_callback_url
...
...
@@ -89,13 +90,19 @@ class GeoNode < ActiveRecord::Base
def
update_dependents_attributes
self
.
geo_node_key
.
title
=
"Geo node:
#{
self
.
url
}
"
if
self
.
geo_node_key
self
.
token
=
SecureRandom
.
hex
(
20
)
if
self
.
token
.
empty?
if
self
.
primary?
self
.
oauth_application
=
nil
else
# OAuth Application
self
.
build_oauth_application
if
oauth_application
.
nil?
self
.
oauth_application
.
name
=
"Geo node:
#{
self
.
url
}
"
self
.
oauth_application
.
redirect_uri
=
oauth_callback_url
# SystemHook
self
.
build_system_hook
if
system_hook
.
nil?
self
.
system_hook
.
url
=
geo_events_url
self
.
system_hook
.
token
=
token
end
end
...
...
db/migrate/20160414032323_add_token_to_geo_node.rb
View file @
7ad4d842
class
AddTokenToGeoNode
<
ActiveRecord
::
Migration
def
change
add_column
:geo_nodes
,
:token
,
:string
# Add token to existing nodes
GeoNode
.
where
(
token:
nil
).
each
do
|
node
|
node
.
token
=
SecureRandom
.
hex
(
20
)
node
.
save!
end
end
end
db/migrate/20160414064845_add_system_hook_to_geo_node.rb
0 → 100644
View file @
7ad4d842
class
AddSystemHookToGeoNode
<
ActiveRecord
::
Migration
def
change
change_table
:geo_nodes
do
|
t
|
t
.
references
:system_hook
end
end
end
db/schema.rb
View file @
7ad4d842
...
...
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
201604140
32323
)
do
ActiveRecord
::
Schema
.
define
(
version:
201604140
64845
)
do
# These are extensions that must be enabled in order to support this database
enable_extension
"plpgsql"
...
...
@@ -421,6 +421,7 @@ ActiveRecord::Schema.define(version: 20160414032323) do
t
.
integer
"geo_node_key_id"
t
.
integer
"oauth_application_id"
t
.
string
"token"
t
.
integer
"system_hook_id"
end
add_index
"geo_nodes"
,
[
"geo_node_key_id"
],
name:
"index_geo_nodes_on_geo_node_key_id"
,
using: :btree
...
...
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