# 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.fetch("GITLAB_API_URL", nil), project_access_token = ENV.fetch("GITLAB_PROJECT_ACCESS_TOKEN", nil) ) @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