debian-mirror-gitlab/app/finders/clusters/agent_tokens_finder.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

26 lines
566 B
Ruby
Raw Normal View History

2023-01-13 00:05:48 +05:30
# 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