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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
299a9a10
Commit
299a9a10
authored
Jan 28, 2013
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
keys to gitolite via sidekiq now
parent
944b2450
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
6 deletions
+30
-6
app/observers/key_observer.rb
app/observers/key_observer.rb
+12
-2
app/workers/gitolite_worker.rb
app/workers/gitolite_worker.rb
+2
-2
lib/gitlab/backend/gitolite.rb
lib/gitlab/backend/gitolite.rb
+16
-2
No files found.
app/observers/key_observer.rb
View file @
299a9a10
...
...
@@ -2,11 +2,21 @@ class KeyObserver < ActiveRecord::Observer
include
Gitolited
def
after_save
(
key
)
gitolite
.
set_key
(
key
.
identifier
,
key
.
key
,
key
.
projects
)
GitoliteWorker
.
perform_async
(
:set_key
,
key
.
identifier
,
key
.
key
,
key
.
projects
.
map
(
&
:id
)
)
end
def
after_destroy
(
key
)
return
if
key
.
is_deploy_key
&&
!
key
.
last_deploy?
gitolite
.
remove_key
(
key
.
identifier
,
key
.
projects
)
GitoliteWorker
.
perform_async
(
:remove_key
,
key
.
identifier
,
key
.
projects
.
map
(
&
:id
)
)
end
end
app/workers/gitolite_worker.rb
View file @
299a9a10
...
...
@@ -4,7 +4,7 @@ class GitoliteWorker
sidekiq_options
queue: :gitolite
def
perform
(
action
,
arg
)
gitolite
.
send
(
action
,
arg
)
def
perform
(
action
,
*
arg
)
gitolite
.
send
(
action
,
*
arg
)
end
end
lib/gitlab/backend/gitolite.rb
View file @
299a9a10
...
...
@@ -8,14 +8,28 @@ module Gitlab
Gitlab
::
GitoliteConfig
.
new
end
def
set_key
key_id
,
key_content
,
projects
# Update gitolite config with new key
#
# Ex.
# set_key("m_gitlab_com_12343", "sha-rsa ...", [2, 3, 6])
#
def
set_key
(
key_id
,
key_content
,
project_ids
)
projects
=
Project
.
where
(
id:
project_ids
)
config
.
apply
do
|
config
|
config
.
write_key
(
key_id
,
key_content
)
config
.
update_projects
(
projects
)
end
end
def
remove_key
key_id
,
projects
# Remove ssh key from gitolite config
#
# Ex.
# remove_key("m_gitlab_com_12343", [2, 3, 6])
#
def
remove_key
(
key_id
,
project_ids
)
projects
=
Project
.
where
(
id:
project_ids
)
config
.
apply
do
|
config
|
config
.
rm_key
(
key_id
)
config
.
update_projects
(
projects
)
...
...
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