Class: SSHKeyHub::Provider::GitLab
- Inherits:
-
Object
- Object
- SSHKeyHub::Provider::GitLab
- Defined in:
- lib/ssh_key_hub/provider/gitlab.rb
Overview
GitLab SSH public key provider
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ GitLab
constructor
A new instance of GitLab.
- #keys_for(group, project = nil) ⇒ Object
-
#keys_for_group_project(group, project) ⇒ Hash
Hash with keys by username with SortedSets.
-
#keys_for_whole_group(group) ⇒ Hash
Hash with keys by username with SortedSets.
Constructor Details
#initialize(options = {}) ⇒ GitLab
Returns a new instance of GitLab
13 14 15 16 17 18 19 |
# File 'lib/ssh_key_hub/provider/gitlab.rb', line 13 def initialize( = {}) = { endpoint: ENV['GITLAB_API_ENDPOINT'] || 'https://gitlab.com/api/v3' } @client = Gitlab.client(.merge()) current_user = @client.user @web_url = current_user.web_url.gsub(current_user.username, '') @is_admin = current_user.is_admin end |
Instance Method Details
#keys_for(group, project = nil) ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/ssh_key_hub/provider/gitlab.rb', line 35 def keys_for(group, project = nil) if project.nil? keys_for_whole_group(group) else keys_for_group_project(group, project) end end |
#keys_for_group_project(group, project) ⇒ Hash
Returns Hash with keys by username with SortedSets
30 31 32 33 |
# File 'lib/ssh_key_hub/provider/gitlab.rb', line 30 def keys_for_group_project(group, project) users = @client.team_members "#{group}/#{project}" keys_for_members users end |
#keys_for_whole_group(group) ⇒ Hash
Returns Hash with keys by username with SortedSets
23 24 25 |
# File 'lib/ssh_key_hub/provider/gitlab.rb', line 23 def keys_for_whole_group(group) keys_for_members(@client.group_members(group)) end |