Class: Gitlab::Kas::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/kas/client.rb

Constant Summary collapse

TIMEOUT =
2.seconds.freeze
JWT_AUDIENCE =
'gitlab-kas'
STUB_CLASSES =
{
  agent_tracker: Gitlab::Agent::AgentTracker::Rpc::AgentTracker::Stub,
  configuration_project: Gitlab::Agent::ConfigurationProject::Rpc::ConfigurationProject::Stub
}.freeze
ConfigurationError =
Class.new(StandardError)

Instance Method Summary collapse

Constructor Details

#initializeClient

Returns a new instance of Client.

Raises:


16
17
18
19
# File 'lib/gitlab/kas/client.rb', line 16

def initialize
  raise ConfigurationError, 'GitLab KAS is not enabled' unless Gitlab::Kas.enabled?
  raise ConfigurationError, 'KAS internal URL is not configured' unless Gitlab::Kas.internal_url.present?
end

Instance Method Details

#get_connected_agents(project:) ⇒ Object


21
22
23
24
25
26
27
28
# File 'lib/gitlab/kas/client.rb', line 21

def get_connected_agents(project:)
  request = Gitlab::Agent::AgentTracker::Rpc::GetConnectedAgentsRequest.new(project_id: project.id)

  stub_for(:agent_tracker)
    .get_connected_agents(request, metadata: )
    .agents
    .to_a
end

#list_agent_config_files(project:) ⇒ Object


30
31
32
33
34
35
36
37
38
39
40
# File 'lib/gitlab/kas/client.rb', line 30

def list_agent_config_files(project:)
  request = Gitlab::Agent::ConfigurationProject::Rpc::ListAgentConfigFilesRequest.new(
    repository: repository(project),
    gitaly_address: gitaly_address(project)
  )

  stub_for(:configuration_project)
    .list_agent_config_files(request, metadata: )
    .config_files
    .to_a
end