summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorLukas Erlacher <erlacher@in.tum.de>2014-08-18 16:46:46 +0200
committerLukas Erlacher <erlacher@in.tum.de>2014-09-03 01:27:02 +0200
commit40fc4261f2e6c8eaf6e885405863e929ecbd47b3 (patch)
tree236e7f674a1983e19a74507fc9d9b54021073caa /app
parent00ccaed029efbbdff96a4b64628a3a2d9bf5125d (diff)
downloadgitlab-ce-40fc4261f2e6c8eaf6e885405863e929ecbd47b3.tar.gz
Add system hook for ssh key changes
Add system hook for ssh key create and destroy Update and fix documentation Update tests
Diffstat (limited to 'app')
-rw-r--r--app/models/key.rb10
-rw-r--r--app/services/system_hooks_service.rb10
2 files changed, 20 insertions, 0 deletions
diff --git a/app/models/key.rb b/app/models/key.rb
index d59993b1905..095c73d8baf 100644
--- a/app/models/key.rb
+++ b/app/models/key.rb
@@ -29,7 +29,9 @@ class Key < ActiveRecord::Base
after_create :add_to_shell
after_create :notify_user
+ after_create :post_create_hook
after_destroy :remove_from_shell
+ after_destroy :post_destroy_hook
def strip_white_space
self.key = key.strip unless key.blank?
@@ -56,6 +58,10 @@ class Key < ActiveRecord::Base
NotificationService.new.new_key(self)
end
+ def post_create_hook
+ SystemHooksService.new.execute_hooks_for(self, :create)
+ end
+
def remove_from_shell
GitlabShellWorker.perform_async(
:remove_key,
@@ -64,6 +70,10 @@ class Key < ActiveRecord::Base
)
end
+ def post_destroy_hook
+ SystemHooksService.new.execute_hooks_for(self, :destroy)
+ end
+
private
def generate_fingerpint
diff --git a/app/services/system_hooks_service.rb b/app/services/system_hooks_service.rb
index 41014f199d5..bfc725e5eb5 100644
--- a/app/services/system_hooks_service.rb
+++ b/app/services/system_hooks_service.rb
@@ -22,6 +22,16 @@ class SystemHooksService
}
case model
+ when Key
+ data.merge!(
+ key: model.key,
+ id: model.id
+ )
+ if model.user
+ data.merge!(
+ username: model.user.username
+ )
+ end
when Project
owner = model.owner