debian-mirror-gitlab/app/graphql/resolvers/kas/agent_configurations_resolver.rb
2022-04-04 11:22:00 +05:30

32 lines
769 B
Ruby

# frozen_string_literal: true
module Resolvers
module Kas
class AgentConfigurationsResolver < BaseResolver
type Types::Kas::AgentConfigurationType, null: true
# Calls Gitaly via KAS
calls_gitaly!
alias_method :project, :object
def resolve
return [] unless can_read_agent_configuration?
kas_client.list_agent_config_files(project: project)
rescue GRPC::BadStatus, Gitlab::Kas::Client::ConfigurationError => e
raise Gitlab::Graphql::Errors::ResourceNotAvailable, e.class.name
end
private
def can_read_agent_configuration?
current_user.can?(:read_cluster, project)
end
def kas_client
@kas_client ||= Gitlab::Kas::Client.new
end
end
end
end