blob: d0b1240157c19de6a1c8f8941c762ae6c9baf6b8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# frozen_string_literal: true
module Clusters
class AgentsFinder
include FinderMethods
def initialize(project, current_user, params: {})
@project = project
@current_user = current_user
@params = params
end
def execute
return ::Clusters::Agent.none unless can_read_cluster_agents?
agents = project.cluster_agents
agents = agents.with_name(params[:name]) if params[:name].present?
agents.ordered_by_name
end
private
attr_reader :project, :current_user, :params
def can_read_cluster_agents?
current_user.can?(:read_cluster, project)
end
end
end
|