Class: Tanuki::Universe::GitlabClient

Inherits:
Object
  • Object
show all
Defined in:
lib/tanuki/universe/gitlab_client.rb

Constant Summary collapse

GITLAB_API_VERSION =
'v4'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ GitlabClient

Returns a new instance of GitlabClient.



11
12
13
14
15
# File 'lib/tanuki/universe/gitlab_client.rb', line 11

def initialize(options)
  parse_options(options)
  endpoint = "#{@opt_url}api/#{GITLAB_API_VERSION}"
  @client = Gitlab.client(endpoint: endpoint, private_token: @opt_private_token)
end

Instance Attribute Details

#projectsObject (readonly)

Returns the value of attribute projects.



9
10
11
# File 'lib/tanuki/universe/gitlab_client.rb', line 9

def projects
  @projects
end

Instance Method Details

#get_git_tags(project_id) ⇒ Object



31
32
33
# File 'lib/tanuki/universe/gitlab_client.rb', line 31

def get_git_tags(project_id)
  @client.tags(project_id)
end

#get_groupsObject



23
24
25
# File 'lib/tanuki/universe/gitlab_client.rb', line 23

def get_groups
  @opt_groups = @client.group_search(@opt_group)
end

#get_metadata(project_id, ref) ⇒ Object



35
36
37
# File 'lib/tanuki/universe/gitlab_client.rb', line 35

def (project_id, ref)
  @client.file_contents(project_id, 'metadata.rb', ref)
end

#get_projects(group_id) ⇒ Object



27
28
29
# File 'lib/tanuki/universe/gitlab_client.rb', line 27

def get_projects(group_id)
   @projects = @client.group(group_id)
end

#parse_options(options) ⇒ Object



17
18
19
20
21
# File 'lib/tanuki/universe/gitlab_client.rb', line 17

def parse_options(options)
  @opt_group = ENV['GITLAB_COOKBOOKS_GROUP'] || options['group']
  @opt_private_token = ENV['GITLAB_API_PRIVATE_TOKEN'] || options['private_token']
  @opt_url = ENV['GITLAB_API_ENDPOINT'] || options['url']
end