Sha256: b19b0dd1c1b41ba1bfb40e78523ead0b36868bdd02ca551e71f4789042de2255

Contents?: true

Size: 815 Bytes

Versions: 6

Compression:

Stored size: 815 Bytes

Contents

# frozen_string_literal: true

require "gitlab"

module CiToolkit
  # Utility class that provides an instance of a Gitlab Client
  class GitlabBot
    attr_reader :client

    # Provides an endpoint and a private access token that can be used with the Gitlab client
    class Credentials
      attr_reader :endpoint, :project_access_token

      def initialize(
        endpoint = ENV["GITLAB_API_URL"],
        project_access_token = ENV["GITLAB_PROJECT_ACCESS_TOKEN"]
      )
        @endpoint = endpoint
        @project_access_token = project_access_token
      end
    end

    def initialize(
      credentials = CiToolkit::GitlabBot::Credentials.new,
      client = Gitlab.client(endpoint: credentials.endpoint, private_token: credentials.project_access_token)
    )
      @client = client
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ci_toolkit-1.5.22 lib/ci_toolkit/gitlab_bot.rb
ci_toolkit-1.5.21 lib/ci_toolkit/gitlab_bot.rb
ci_toolkit-1.5.20 lib/ci_toolkit/gitlab_bot.rb
ci_toolkit-1.5.19 lib/ci_toolkit/gitlab_bot.rb
ci_toolkit-1.5.17 lib/ci_toolkit/gitlab_bot.rb
ci_toolkit-1.5.16 lib/ci_toolkit/gitlab_bot.rb