Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-06-16 21:25:58 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-06-16 21:25:58 +0300
commita5f4bba440d7f9ea47046a0a561d49adf0a1e6d4 (patch)
treefb69158581673816a8cd895f9d352dcb3c678b1e /app/graphql/mutations
parentd16b2e8639e99961de6ddc93909f3bb5c1445ba1 (diff)
Add latest changes from gitlab-org/gitlab@14-0-stable-eev14.0.0-rc42
Diffstat (limited to 'app/graphql/mutations')
-rw-r--r--app/graphql/mutations/ci/ci_cd_settings_update.rb4
-rw-r--r--app/graphql/mutations/ci/runner/delete.rb44
-rw-r--r--app/graphql/mutations/ci/runner/update.rb68
-rw-r--r--app/graphql/mutations/ci/runners_registration_token/reset.rb66
-rw-r--r--app/graphql/mutations/commits/create.rb6
-rw-r--r--app/graphql/mutations/concerns/mutations/resolves_subscription.rb1
-rw-r--r--app/graphql/mutations/issues/set_subscription.rb24
-rw-r--r--app/graphql/mutations/labels/create.rb4
-rw-r--r--app/graphql/mutations/merge_requests/set_subscription.rb24
-rw-r--r--app/graphql/mutations/snippets/create.rb2
-rw-r--r--app/graphql/mutations/snippets/update.rb2
-rw-r--r--app/graphql/mutations/todos/mark_all_done.rb7
-rw-r--r--app/graphql/mutations/todos/restore_many.rb5
13 files changed, 237 insertions, 20 deletions
diff --git a/app/graphql/mutations/ci/ci_cd_settings_update.rb b/app/graphql/mutations/ci/ci_cd_settings_update.rb
index a484c2438a4..0973e9beae3 100644
--- a/app/graphql/mutations/ci/ci_cd_settings_update.rb
+++ b/app/graphql/mutations/ci/ci_cd_settings_update.rb
@@ -17,6 +17,10 @@ module Mutations
required: false,
description: 'Indicates if the latest artifact should be kept for this project.'
+ argument :job_token_scope_enabled, GraphQL::BOOLEAN_TYPE,
+ required: false,
+ description: 'Indicates CI job tokens generated in this project have restricted access to resources.'
+
field :ci_cd_settings,
Types::Ci::CiCdSettingType,
null: false,
diff --git a/app/graphql/mutations/ci/runner/delete.rb b/app/graphql/mutations/ci/runner/delete.rb
new file mode 100644
index 00000000000..8d9a5f15505
--- /dev/null
+++ b/app/graphql/mutations/ci/runner/delete.rb
@@ -0,0 +1,44 @@
+# frozen_string_literal: true
+
+module Mutations
+ module Ci
+ module Runner
+ class Delete < BaseMutation
+ graphql_name 'RunnerDelete'
+
+ authorize :delete_runner
+
+ RunnerID = ::Types::GlobalIDType[::Ci::Runner]
+
+ argument :id, RunnerID,
+ required: true,
+ description: 'ID of the runner to delete.'
+
+ def resolve(id:, **runner_attrs)
+ runner = authorized_find!(id)
+
+ error = authenticate_delete_runner!(runner)
+ return { errors: [error] } if error
+
+ runner.destroy!
+
+ { errors: runner.errors.full_messages }
+ end
+
+ def authenticate_delete_runner!(runner)
+ return if current_user.can_admin_all_resources?
+
+ "Runner #{runner.to_global_id} associated with more than one project" if runner.projects.count > 1
+ end
+
+ def find_object(id)
+ # TODO: remove this line when the compatibility layer is removed
+ # See: https://gitlab.com/gitlab-org/gitlab/-/issues/257883
+ id = RunnerID.coerce_isolated_input(id)
+
+ GitlabSchema.find_by_gid(id)
+ end
+ end
+ end
+ end
+end
diff --git a/app/graphql/mutations/ci/runner/update.rb b/app/graphql/mutations/ci/runner/update.rb
new file mode 100644
index 00000000000..5b61b2ffc0d
--- /dev/null
+++ b/app/graphql/mutations/ci/runner/update.rb
@@ -0,0 +1,68 @@
+# frozen_string_literal: true
+
+module Mutations
+ module Ci
+ module Runner
+ class Update < BaseMutation
+ graphql_name 'RunnerUpdate'
+
+ authorize :update_runner
+
+ RunnerID = ::Types::GlobalIDType[::Ci::Runner]
+
+ argument :id, RunnerID,
+ required: true,
+ description: 'ID of the runner to update.'
+
+ argument :description, GraphQL::STRING_TYPE,
+ required: false,
+ description: 'Description of the runner.'
+
+ argument :maximum_timeout, GraphQL::INT_TYPE,
+ required: false,
+ description: 'Maximum timeout (in seconds) for jobs processed by the runner.'
+
+ argument :access_level, ::Types::Ci::RunnerAccessLevelEnum,
+ required: false,
+ description: 'Access level of the runner.'
+
+ argument :active, GraphQL::BOOLEAN_TYPE,
+ required: false,
+ description: 'Indicates the runner is allowed to receive jobs.'
+
+ argument :locked, GraphQL::BOOLEAN_TYPE, required: false,
+ description: 'Indicates the runner is locked.'
+
+ argument :run_untagged, GraphQL::BOOLEAN_TYPE,
+ required: false,
+ description: 'Indicates the runner is able to run untagged jobs.'
+
+ argument :tag_list, [GraphQL::STRING_TYPE], required: false,
+ description: 'Tags associated with the runner.'
+
+ field :runner,
+ Types::Ci::RunnerType,
+ null: true,
+ description: 'The runner after mutation.'
+
+ def resolve(id:, **runner_attrs)
+ runner = authorized_find!(id)
+
+ unless ::Ci::UpdateRunnerService.new(runner).update(runner_attrs)
+ return { runner: nil, errors: runner.errors.full_messages }
+ end
+
+ { runner: runner, errors: [] }
+ end
+
+ def find_object(id)
+ # TODO: remove this line when the compatibility layer is removed
+ # See: https://gitlab.com/gitlab-org/gitlab/-/issues/257883
+ id = RunnerID.coerce_isolated_input(id)
+
+ GitlabSchema.find_by_gid(id)
+ end
+ end
+ end
+ end
+end
diff --git a/app/graphql/mutations/ci/runners_registration_token/reset.rb b/app/graphql/mutations/ci/runners_registration_token/reset.rb
new file mode 100644
index 00000000000..e1cdd9a22a5
--- /dev/null
+++ b/app/graphql/mutations/ci/runners_registration_token/reset.rb
@@ -0,0 +1,66 @@
+# frozen_string_literal: true
+
+module Mutations
+ module Ci
+ module RunnersRegistrationToken
+ class Reset < BaseMutation
+ graphql_name 'RunnersRegistrationTokenReset'
+
+ authorize :update_runners_registration_token
+
+ ScopeID = ::GraphQL::ID_TYPE
+
+ argument :type, ::Types::Ci::RunnerTypeEnum,
+ required: true,
+ description: 'Scope of the object to reset the token for.'
+
+ argument :id, ScopeID,
+ required: false,
+ description: 'ID of the project or group to reset the token for. Omit if resetting instance runner token.'
+
+ field :token,
+ GraphQL::STRING_TYPE,
+ null: true,
+ description: 'The runner token after mutation.'
+
+ def resolve(**args)
+ {
+ token: reset_token(**args),
+ errors: []
+ }
+ end
+
+ private
+
+ def find_object(type:, **args)
+ id = args[:id]
+
+ case type
+ when 'group_type'
+ GitlabSchema.object_from_id(id, expected_type: ::Group)
+ when 'project_type'
+ GitlabSchema.object_from_id(id, expected_type: ::Project)
+ end
+ end
+
+ def reset_token(type:, **args)
+ id = args[:id]
+
+ case type
+ when 'instance_type'
+ raise Gitlab::Graphql::Errors::ArgumentError, "id must not be specified for '#{type}' scope" if id.present?
+
+ authorize!(:global)
+
+ ApplicationSetting.current.reset_runners_registration_token!
+ ApplicationSetting.current_without_cache.runners_registration_token
+ when 'group_type', 'project_type'
+ project_or_group = authorized_find!(type: type, id: id)
+ project_or_group.reset_runners_token!
+ project_or_group.runners_token
+ end
+ end
+ end
+ end
+ end
+end
diff --git a/app/graphql/mutations/commits/create.rb b/app/graphql/mutations/commits/create.rb
index 2e06e1ea0c4..f432f679909 100644
--- a/app/graphql/mutations/commits/create.rb
+++ b/app/graphql/mutations/commits/create.rb
@@ -44,6 +44,11 @@ module Mutations
null: true,
description: 'The commit after mutation.'
+ field :content,
+ [GraphQL::STRING_TYPE],
+ null: true,
+ description: 'Contents of the commit.'
+
authorize :push_code
def resolve(project_path:, branch:, message:, actions:, **args)
@@ -59,6 +64,7 @@ module Mutations
result = ::Files::MultiService.new(project, current_user, attributes).execute
{
+ content: actions.pluck(:content), # rubocop:disable CodeReuse/ActiveRecord because actions is an Array, not a Relation
commit: (project.repository.commit(result[:result]) if result[:status] == :success),
commit_pipeline_path: UrlHelpers.new.graphql_etag_pipeline_sha_path(result[:result]),
errors: Array.wrap(result[:message])
diff --git a/app/graphql/mutations/concerns/mutations/resolves_subscription.rb b/app/graphql/mutations/concerns/mutations/resolves_subscription.rb
index e26ae7d228c..ed9fb5fceb0 100644
--- a/app/graphql/mutations/concerns/mutations/resolves_subscription.rb
+++ b/app/graphql/mutations/concerns/mutations/resolves_subscription.rb
@@ -3,6 +3,7 @@
module Mutations
module ResolvesSubscription
extend ActiveSupport::Concern
+
included do
argument :subscribed_state,
GraphQL::BOOLEAN_TYPE,
diff --git a/app/graphql/mutations/issues/set_subscription.rb b/app/graphql/mutations/issues/set_subscription.rb
index a04c8f5ba2d..55c9049b7cf 100644
--- a/app/graphql/mutations/issues/set_subscription.rb
+++ b/app/graphql/mutations/issues/set_subscription.rb
@@ -2,10 +2,32 @@
module Mutations
module Issues
- class SetSubscription < Base
+ class SetSubscription < BaseMutation
graphql_name 'IssueSetSubscription'
include ResolvesSubscription
+ include Mutations::ResolvesIssuable
+
+ argument :project_path, GraphQL::ID_TYPE,
+ required: true,
+ description: "The project the issue to mutate is in."
+
+ argument :iid, GraphQL::STRING_TYPE,
+ required: true,
+ description: "The IID of the issue to mutate."
+
+ field :issue,
+ Types::IssueType,
+ null: true,
+ description: "The issue after mutation."
+
+ authorize :update_subscription
+
+ private
+
+ def find_object(project_path:, iid:)
+ resolve_issuable(type: :issue, parent_path: project_path, iid: iid)
+ end
end
end
end
diff --git a/app/graphql/mutations/labels/create.rb b/app/graphql/mutations/labels/create.rb
index 4da628d53ea..683d0b44586 100644
--- a/app/graphql/mutations/labels/create.rb
+++ b/app/graphql/mutations/labels/create.rb
@@ -20,10 +20,6 @@ module Mutations
required: false,
description: 'Description of the label.'
- argument :remove_on_close, GraphQL::BOOLEAN_TYPE,
- required: false,
- description: copy_field_description(Types::LabelType, :remove_on_close)
-
argument :color, GraphQL::STRING_TYPE,
required: false,
default_value: Label::DEFAULT_COLOR,
diff --git a/app/graphql/mutations/merge_requests/set_subscription.rb b/app/graphql/mutations/merge_requests/set_subscription.rb
index 7d3c40185c9..981daa81c28 100644
--- a/app/graphql/mutations/merge_requests/set_subscription.rb
+++ b/app/graphql/mutations/merge_requests/set_subscription.rb
@@ -2,10 +2,32 @@
module Mutations
module MergeRequests
- class SetSubscription < Base
+ class SetSubscription < BaseMutation
graphql_name 'MergeRequestSetSubscription'
include ResolvesSubscription
+ include Mutations::ResolvesIssuable
+
+ argument :project_path, GraphQL::ID_TYPE,
+ required: true,
+ description: "The project the merge request to mutate is in."
+
+ argument :iid, GraphQL::STRING_TYPE,
+ required: true,
+ description: "The IID of the merge request to mutate."
+
+ field :merge_request,
+ Types::MergeRequestType,
+ null: true,
+ description: "The merge request after mutation."
+
+ authorize :update_subscription
+
+ private
+
+ def find_object(project_path:, iid:)
+ resolve_issuable(type: :merge_request, parent_path: project_path, iid: iid)
+ end
end
end
end
diff --git a/app/graphql/mutations/snippets/create.rb b/app/graphql/mutations/snippets/create.rb
index e9b45294659..d1ad0697acd 100644
--- a/app/graphql/mutations/snippets/create.rb
+++ b/app/graphql/mutations/snippets/create.rb
@@ -49,7 +49,7 @@ module Mutations
process_args_for_params!(args)
- service_response = ::Snippets::CreateService.new(project, current_user, args).execute
+ service_response = ::Snippets::CreateService.new(project: project, current_user: current_user, params: args).execute
# Only when the user is not an api user and the operation was successful
if !api_user? && service_response.success?
diff --git a/app/graphql/mutations/snippets/update.rb b/app/graphql/mutations/snippets/update.rb
index b9b9b13eebb..2e1382e1cb1 100644
--- a/app/graphql/mutations/snippets/update.rb
+++ b/app/graphql/mutations/snippets/update.rb
@@ -34,7 +34,7 @@ module Mutations
process_args_for_params!(args)
- service_response = ::Snippets::UpdateService.new(snippet.project, current_user, args).execute(snippet)
+ service_response = ::Snippets::UpdateService.new(project: snippet.project, current_user: current_user, params: args).execute(snippet)
# TODO: DRY this up - From here down, this is all duplicated with Mutations::Snippets::Create#resolve, except for
# `snippet.reset`, which is required in order to return the object in its non-dirty, unmodified, database state
diff --git a/app/graphql/mutations/todos/mark_all_done.rb b/app/graphql/mutations/todos/mark_all_done.rb
index 22a5893d4ec..7dd06cc8293 100644
--- a/app/graphql/mutations/todos/mark_all_done.rb
+++ b/app/graphql/mutations/todos/mark_all_done.rb
@@ -7,12 +7,6 @@ module Mutations
authorize :update_user
- field :updated_ids,
- [::Types::GlobalIDType[::Todo]],
- null: false,
- deprecated: { reason: 'Use to-do items', milestone: '13.2' },
- description: 'IDs of the updated to-do items.'
-
field :todos, [::Types::TodoType],
null: false,
description: 'Updated to-do items.'
@@ -23,7 +17,6 @@ module Mutations
updated_ids = mark_all_todos_done
{
- updated_ids: updated_ids,
todos: Todo.id_in(updated_ids),
errors: []
}
diff --git a/app/graphql/mutations/todos/restore_many.rb b/app/graphql/mutations/todos/restore_many.rb
index 41ccbd77aa6..b09c59a3435 100644
--- a/app/graphql/mutations/todos/restore_many.rb
+++ b/app/graphql/mutations/todos/restore_many.rb
@@ -12,11 +12,6 @@ module Mutations
required: true,
description: 'The global IDs of the to-do items to restore (a maximum of 50 is supported at once).'
- field :updated_ids, [::Types::GlobalIDType[Todo]],
- null: false,
- description: 'The IDs of the updated to-do items.',
- deprecated: { reason: 'Use to-do items', milestone: '13.2' }
-
field :todos, [::Types::TodoType],
null: false,
description: 'Updated to-do items.'