Skip to content
Snippets Groups Projects
Verified Commit 072d7a0b authored by Timo Furrer's avatar Timo Furrer :juggling:
Browse files

Move Receptive Agents GraphQL API into EE

parent 6bc2ebfd
1 merge request!164184Move Receptive Agents feature to Ultimate
Showing
with 66 additions and 17 deletions
......@@ -66,16 +66,6 @@ class AgentType < BaseObject
null: true,
description: 'User access config for the cluster agent.'
field :is_receptive,
GraphQL::Types::Boolean,
null: true,
description: 'Whether the cluster agent is receptive or not.'
field :url_configurations,
AgentUrlConfigurationType.connection_type,
null: true,
description: 'URL configurations for the cluster agent in case it is a receptive agent.'
def project
Gitlab::Graphql::Loaders::BatchModelLoader.new(Project, object.project_id).find
end
......@@ -83,10 +73,6 @@ def project
def web_path
::Gitlab::Routing.url_helpers.project_cluster_agent_path(object.project, object.name)
end
def url_configurations
[object.agent_url_configuration]
end
end
end
end
......
......@@ -44,8 +44,6 @@ class MutationType < BaseObject
mount_mutation Mutations::Clusters::Agents::Delete
mount_mutation Mutations::Clusters::AgentTokens::Create
mount_mutation Mutations::Clusters::AgentTokens::Revoke
mount_mutation Mutations::Clusters::AgentUrlConfigurations::Create
mount_mutation Mutations::Clusters::AgentUrlConfigurations::Delete
mount_mutation Mutations::Commits::Create, calls_gitaly: true
mount_mutation Mutations::CustomEmoji::Create
mount_mutation Mutations::CustomEmoji::Destroy
......
......@@ -7,6 +7,16 @@ module AgentType
extend ActiveSupport::Concern
prepended do
field :is_receptive,
GraphQL::Types::Boolean,
null: true,
description: 'Whether the cluster agent is receptive or not.'
field :url_configurations,
::Types::Clusters::AgentUrlConfigurationType.connection_type,
null: true,
description: 'URL configurations for the cluster agent in case it is a receptive agent.'
field :vulnerability_images,
type: ::Types::Vulnerabilities::ContainerImageType.connection_type,
null: true,
......@@ -33,6 +43,10 @@ module AgentType
null: true,
description: 'Workspaces agent config for the cluster agent.',
resolver: ::Resolvers::RemoteDevelopment::WorkspacesAgentConfigForAgentResolver
def url_configurations
[object.agent_url_configuration]
end
end
end
end
......
......@@ -13,6 +13,8 @@ def self.authorization_scopes
mount_mutation ::Mutations::Ci::Catalog::VerifiedNamespace::Create
mount_mutation ::Mutations::Ci::ProjectSubscriptions::Create
mount_mutation ::Mutations::Ci::ProjectSubscriptions::Delete
mount_mutation ::Mutations::Clusters::AgentUrlConfigurations::Create
mount_mutation ::Mutations::Clusters::AgentUrlConfigurations::Delete
mount_mutation ::Mutations::ComplianceManagement::Frameworks::Destroy
mount_mutation ::Mutations::ComplianceManagement::Frameworks::Update
mount_mutation ::Mutations::ComplianceManagement::Frameworks::Create
......
......@@ -8,6 +8,10 @@
let_it_be(:cluster_agent) { create(:cluster_agent) }
let_it_be(:current_user) { create(:user) }
before do
stub_licensed_features(cluster_receptive_agents: true)
end
subject(:mutation) { described_class.new(object: nil, context: query_context, field: nil) }
specify { expect(described_class).to require_graphql_authorizations(:create_cluster) }
......@@ -97,6 +101,18 @@
end
end
context 'when receptive agents feature is disabled because of the tier' do
before do
stub_licensed_features(cluster_receptive_agents: false)
cluster_agent.project.add_maintainer(current_user)
end
it 'raises an error' do
expect { mutate }.not_to change { ::Clusters::Agents::UrlConfiguration.count }
expect(mutate[:errors]).to eq(["Receptive agents are unavailable for this GitLab instance"])
end
end
context 'when receptive agents are disabled' do
before do
stub_application_setting(receptive_cluster_agents_enabled: false)
......
......@@ -16,6 +16,10 @@
)
end
before do
stub_licensed_features(cluster_receptive_agents: true)
end
it { expect(described_class.graphql_name).to eq('ClusterAgentUrlConfigurationDelete') }
it { expect(described_class).to require_graphql_authorizations(:admin_cluster) }
......@@ -48,6 +52,19 @@
end
end
context 'when receptive agents feature is disabled because of the tier' do
before do
stub_licensed_features(cluster_receptive_agents: false)
url_configuration.agent.project.add_maintainer(current_user)
end
it 'raises an error' do
expect { mutate }.not_to change { ::Clusters::Agents::UrlConfiguration.count }
expect { url_configuration.reload }.not_to raise_error
expect(mutate[:errors]).to eq(["Receptive agents are unavailable for this GitLab instance"])
end
end
context 'when receptive agents are disabled' do
before do
stub_application_setting(receptive_cluster_agents_enabled: false)
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe GitlabSchema.types['ClusterAgent'], feature_category: :deployment_management do # rubocop:disable RSpec/DuplicateSpecLocation -- EE spec
let(:fields) do
%i[created_at created_by_user id name project updated_at tokens web_path connections activity_events
user_access_authorizations is_receptive url_configurations]
end
it { expect(described_class.graphql_name).to eq('ClusterAgent') }
it { expect(described_class).to require_graphql_authorizations(:read_cluster_agent) }
it { expect(described_class).to include_graphql_fields(*fields) }
end
......@@ -5,7 +5,7 @@
RSpec.describe GitlabSchema.types['ClusterAgent'], feature_category: :deployment_management do
let(:fields) do
%i[created_at created_by_user id name project updated_at tokens web_path connections activity_events
user_access_authorizations is_receptive url_configurations]
user_access_authorizations]
end
it { expect(described_class.graphql_name).to eq('ClusterAgent') }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment