Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-11-22 09:08:04 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-11-22 09:08:04 +0300
commit0c0c7f1891cf22db904423b0a5398150a385995f (patch)
tree3cc0eec0be7aa9b2045198286c61c7398ff9749d /app/finders
parente0b6b475f203ebbe63a903328369c1363a747498 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/finders')
-rw-r--r--app/finders/clusters/agent_tokens_finder.rb15
1 files changed, 7 insertions, 8 deletions
diff --git a/app/finders/clusters/agent_tokens_finder.rb b/app/finders/clusters/agent_tokens_finder.rb
index e241836e1dc..60609fa6c6d 100644
--- a/app/finders/clusters/agent_tokens_finder.rb
+++ b/app/finders/clusters/agent_tokens_finder.rb
@@ -2,24 +2,23 @@
module Clusters
class AgentTokensFinder
- def initialize(object, current_user, agent_id)
- @object = object
+ def initialize(agent, current_user)
+ @agent = agent
@current_user = current_user
- @agent_id = agent_id
end
def execute
- raise_not_found_unless_can_read_cluster
+ return ::Clusters::AgentToken.none unless can_read_cluster_agents?
- object.cluster_agents.find(agent_id).agent_tokens
+ agent.agent_tokens
end
private
- attr_reader :object, :current_user, :agent_id
+ attr_reader :agent, :current_user
- def raise_not_found_unless_can_read_cluster
- raise ActiveRecord::RecordNotFound unless current_user&.can?(:read_cluster, object)
+ def can_read_cluster_agents?
+ current_user&.can?(:read_cluster, agent&.project)
end
end
end