Class: Gitlab::Kas::Client
- Inherits:
-
Object
- Object
- Gitlab::Kas::Client
- 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, notifications: Gitlab::Agent::Notifications::Rpc::Notifications::Stub }.freeze
- ConfigurationError =
Class.new(StandardError)
Instance Method Summary collapse
- #get_connected_agents(project:) ⇒ Object
-
#initialize ⇒ Client
constructor
A new instance of Client.
- #list_agent_config_files(project:) ⇒ Object
- #send_git_push_event(project:) ⇒ Object
Constructor Details
#initialize ⇒ Client
Returns a new instance of Client.
17 18 19 20 |
# File 'lib/gitlab/kas/client.rb', line 17 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
22 23 24 25 26 27 28 29 |
# File 'lib/gitlab/kas/client.rb', line 22 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
31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/gitlab/kas/client.rb', line 31 def list_agent_config_files(project:) request = Gitlab::Agent::ConfigurationProject::Rpc::ListAgentConfigFilesRequest.new( repository: repository(project), gitaly_info: gitaly_info(project) ) stub_for(:configuration_project) .list_agent_config_files(request, metadata: ) .config_files .to_a end |
#send_git_push_event(project:) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/gitlab/kas/client.rb', line 43 def send_git_push_event(project:) request = Gitlab::Agent::Notifications::Rpc::GitPushEventRequest.new( event: Gitlab::Agent::Event::GitPushEvent.new( project: Gitlab::Agent::Event::Project.new( id: project.id, full_path: project.full_path ) ) ) stub_for(:notifications) .git_push_event(request, metadata: ) end |