Add system hook for ssh key changes
Created by: duk3luk3
Enabling SSH Key create/delete notification in system hooks makes it possible to automatically push ssh keys to other systems so gitlab can be more tightly integrated with a development environment.
Code is self-explaining. It adds after_create and after_destroy hooks to the Key model and adds logic to process a Key update in the build_event_data method of the system hook service.
Created by: TeatroIO
I've prepared a stage. Click to open.
By Administrator on 2014-08-18T14:55:54 (imported from GitLab project)
22 22 } 23 23 24 24 case model 25 when Key 26 data.merge!( 27 key: model.key, 28 id: model.id 29 ) 30 if model.user Created by: duk3luk3
Corresponding feedback post is here: http://feedback.gitlab.com/forums/176466-general/suggestions/6311549-add-ssh-keys-to-system-hooks
By Administrator on 2014-08-18T14:59:16 (imported from GitLab project)
21 24 it { event_name(project, :destroy).should eq "project_destroy" } 22 25 it { event_name(users_project, :create).should eq "user_add_to_team" } 23 26 it { event_name(users_project, :destroy).should eq "user_remove_from_team" } 27 it { event_name(key, :create).should eq 'key_create' } 21 24 it { event_name(project, :destroy).should eq "project_destroy" } 22 25 it { event_name(users_project, :create).should eq "user_add_to_team" } 23 26 it { event_name(users_project, :destroy).should eq "user_remove_from_team" } 27 it { event_name(key, :create).should eq 'key_create' } 28 it { event_name(key, :destroy).should eq 'key_destroy' } Created by: Razer6
I think this are the event names like on the testcases https://github.com/duk3luk3/gitlabhq/blob/system-hook-key-feature/spec/services/system_hooks_service_spec.rb#L20 However, they are not consistent with the documentation. Since you update, could you fix the other ones?
By Administrator on 2014-08-18T18:55:29 (imported from GitLab project)
Created by: duk3luk3
I fixed all the hound warnings that actually showed a discrepancy to the coding style of the files I was editing. If I fix them all, I also have to fix up the rest of the file, and I'll be touching the entire file and not just where I actually added/changed program logic. Should I put the style fixups into a separate commit to make it easier to see the program logic changes?
By Administrator on 2014-08-18T19:08:26 (imported from GitLab project)
56 58 NotificationService.new.new_key(self) 57 59 end 58 60 61 def post_create_hook 62 SystemHooksService.new.execute_hooks_for(self, :create) 56 58 NotificationService.new.new_key(self) 57 59 end 58 60 61 def post_create_hook 62 SystemHooksService.new.execute_hooks_for(self, :create) Created by: duk3luk3
Could it be that the key-related tests are failing because of
Warning You are running as user travis, we hope you know what you are doing. Things may work/fail for the wrong reasons. For correct results you should run this as user git.
?
There are errors like this happening:
................................../home/travis/build/gitlabhq/gitlabhq/tmp/tests/gitlab-shell/lib/gitlab_keys.rb:87:in `initialize': No such file or directory - /home/git/.ssh/authorized_keys.lock (Errno::ENOENT)
That seems to be a problem with the test configuration.
My code is failing because it expects keys that belong to a user but is called with key instances where user is nil. It seems that that is valid so I'll change it in my code.
By Administrator on 2014-08-19T17:46:25 (imported from GitLab project)
Created by: duk3luk3
Here is the successful test from 12 days ago: https://travis-ci.org/gitlabhq/gitlabhq/builds/33086108
All that was changed in that time is that I merged in CHANGELOG.
By Administrator on 2014-09-03T10:04:03 (imported from GitLab project)