2021-11-18 22:05:49 +05:30
|
|
|
# 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)
|
2022-01-26 12:08:38 +05:30
|
|
|
rescue GRPC::BadStatus, Gitlab::Kas::Client::ConfigurationError => e
|
2021-11-18 22:05:49 +05:30
|
|
|
raise Gitlab::Graphql::Errors::ResourceNotAvailable, e.class.name
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def can_read_agent_configuration?
|
2022-04-04 11:22:00 +05:30
|
|
|
current_user.can?(:read_cluster, project)
|
2021-11-18 22:05:49 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def kas_client
|
|
|
|
@kas_client ||= Gitlab::Kas::Client.new
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|