add remove keys from gitlab-shell by id

This commit is contained in:
Dmitriy Zaporozhets 2013-02-05 11:12:15 +02:00
parent 081c272b85
commit 39e37677f2
3 changed files with 10 additions and 10 deletions

View file

@ -81,7 +81,7 @@ class Key < ActiveRecord::Base
Key.where(identifier: identifier).count == 0 Key.where(identifier: identifier).count == 0
end end
def owner_name def shell_id
user.username "key-#{self.id}"
end end
end end

View file

@ -4,7 +4,7 @@ class KeyObserver < ActiveRecord::Observer
def after_save(key) def after_save(key)
GitoliteWorker.perform_async( GitoliteWorker.perform_async(
:add_key, :add_key,
key.owner_name, key.shell_id,
key.key key.key
) )
end end
@ -12,7 +12,7 @@ class KeyObserver < ActiveRecord::Observer
def after_destroy(key) def after_destroy(key)
GitoliteWorker.perform_async( GitoliteWorker.perform_async(
:remove_key, :remove_key,
key.owner_name, key.shell_id,
key.key, key.key,
) )
end end

View file

@ -27,19 +27,19 @@ module Gitlab
# Add new key to gitlab-shell # Add new key to gitlab-shell
# #
# Ex. # Ex.
# add_key("randx", "sha-rsa ...") # add_key("key-42", "sha-rsa ...")
# #
def add_key(username, key_content) def add_key(key_id, key_content)
system("/home/git/gitlab-shell/bin/gitlab-keys add-key #{username} \"#{key_content}\"") system("/home/git/gitlab-shell/bin/gitlab-keys add-key #{key_id} \"#{key_content}\"")
end end
# Remove ssh key from gitlab shell # Remove ssh key from gitlab shell
# #
# Ex. # Ex.
# remove_key("sha-rsa") # remove_key("key-342", "sha-rsa ...")
# #
def remove_key(username, key_content) def remove_key(key_id, key_content)
system("/home/git/gitlab-shell/bin/gitlab-keys rm-key #{username} \"#{key_content}\"") system("/home/git/gitlab-shell/bin/gitlab-keys rm-key #{key_id} \"#{key_content}\"")
end end