Sha256: 4f89c07a8d916f0c1c0b3e28fc16926342532ee63c928c038a3beff0b9076d59

Contents?: true

Size: 952 Bytes

Versions: 1

Compression:

Stored size: 952 Bytes

Contents

require 'gitlab'

module Tanuki
  module Universe
    class GitlabClient

      GITLAB_API_VERSION = 'v4'

      attr_reader :group, :private_token, :url, :projects

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

      def parse_options(options)
        @group = ENV['GITLAB_COOKBOOKS_GROUP'] || options['group']
        @private_token = ENV['GITLAB_API_PRIVATETOKEN'] || options['private_token']
        @url = ENV['GITLAB_API_ENDPOINT'] || options['url']
      end
      
      def get_projects
        @projects = @client.project_search(@group)
      end

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

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

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tanuki-universe-0.0.3 lib/tanuki/universe/gitlab_client.rb