diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-12-03 00:07:10 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-12-03 00:07:10 +0300 |
commit | ec8cf3f7c8d9ac408a81af714db7a0640cf0199d (patch) | |
tree | cbe011f521781fe98c656330cb5f42703bd71c03 /app/finders | |
parent | af833d9730dd367984b55ef02ccc3fe6eb83f0e4 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/finders')
-rw-r--r-- | app/finders/clusters/agent_tokens_finder.rb | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/app/finders/clusters/agent_tokens_finder.rb b/app/finders/clusters/agent_tokens_finder.rb index c0d1f911d92..72692777bc6 100644 --- a/app/finders/clusters/agent_tokens_finder.rb +++ b/app/finders/clusters/agent_tokens_finder.rb @@ -4,20 +4,25 @@ module Clusters class AgentTokensFinder include FinderMethods - def initialize(agent, current_user) + def initialize(agent, current_user, params = {}) @agent = agent @current_user = current_user + @params = params end def execute return ::Clusters::AgentToken.none unless can_read_cluster_agents? - agent.agent_tokens + agent.agent_tokens.then { |agent_tokens| by_status(agent_tokens) } end private - attr_reader :agent, :current_user + attr_reader :agent, :current_user, :params + + def by_status(agent_tokens) + params[:status].present? ? agent_tokens.with_status(params[:status]) : agent_tokens + end def can_read_cluster_agents? current_user&.can?(:read_cluster, agent&.project) |