debian-mirror-gitlab/app/graphql/resolvers/clusters/agent_tokens_resolver.rb

26 lines
515 B
Ruby
Raw Normal View History

2021-11-18 22:05:49 +05:30
# frozen_string_literal: true
module Resolvers
module Clusters
class AgentTokensResolver < BaseResolver
type Types::Clusters::AgentTokenType, null: true
alias_method :agent, :object
delegate :project, to: :agent
def resolve(**args)
return ::Clusters::AgentToken.none unless can_read_agent_tokens?
agent.last_used_agent_tokens
end
private
def can_read_agent_tokens?
current_user.can?(:admin_cluster, project)
end
end
end
end