diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-14 06:08:13 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-11-14 06:08:13 +0300 |
commit | 3f2ce963ab6f19c6f4c910406c0b06cf4772fc30 (patch) | |
tree | a86515e59ebad9d8b3cc6bd2fc8d3accbbacabe7 /app/finders | |
parent | 2b8ac36bdd626226a93e6759b44bdcb5decc1559 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/finders')
-rw-r--r-- | app/finders/clusters/agent_tokens_finder.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/app/finders/clusters/agent_tokens_finder.rb b/app/finders/clusters/agent_tokens_finder.rb new file mode 100644 index 00000000000..e241836e1dc --- /dev/null +++ b/app/finders/clusters/agent_tokens_finder.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +module Clusters + class AgentTokensFinder + def initialize(object, current_user, agent_id) + @object = object + @current_user = current_user + @agent_id = agent_id + end + + def execute + raise_not_found_unless_can_read_cluster + + object.cluster_agents.find(agent_id).agent_tokens + end + + private + + attr_reader :object, :current_user, :agent_id + + def raise_not_found_unless_can_read_cluster + raise ActiveRecord::RecordNotFound unless current_user&.can?(:read_cluster, object) + end + end +end |