diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-22 18:07:44 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-02-22 18:07:44 +0000 |
commit | d0f16d56f3716d4a60027eb261f12080094f8db3 (patch) | |
tree | f9ecf9f4bda6d761f612bc4a5efb701b7c6b3d2d /app/graphql/mutations | |
parent | 68aa32736b50c3609348f3bf740b81a2dfd1fb25 (diff) | |
download | gitlab-ce-d0f16d56f3716d4a60027eb261f12080094f8db3.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/graphql/mutations')
-rw-r--r-- | app/graphql/mutations/ci/runner/common_mutation_arguments.rb | 50 | ||||
-rw-r--r-- | app/graphql/mutations/ci/runner/create.rb | 44 | ||||
-rw-r--r-- | app/graphql/mutations/ci/runner/update.rb | 39 |
3 files changed, 96 insertions, 37 deletions
diff --git a/app/graphql/mutations/ci/runner/common_mutation_arguments.rb b/app/graphql/mutations/ci/runner/common_mutation_arguments.rb new file mode 100644 index 00000000000..bfeed4881c6 --- /dev/null +++ b/app/graphql/mutations/ci/runner/common_mutation_arguments.rb @@ -0,0 +1,50 @@ +# frozen_string_literal: true + +module Mutations + module Ci + module Runner + module CommonMutationArguments + extend ActiveSupport::Concern + + included do + argument :description, GraphQL::Types::String, + required: false, + description: 'Description of the runner.' + + argument :maintenance_note, GraphQL::Types::String, + required: false, + description: 'Runner\'s maintenance notes.' + + argument :maximum_timeout, GraphQL::Types::Int, + 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 :paused, GraphQL::Types::Boolean, + required: false, + description: 'Indicates the runner is not allowed to receive jobs.' + + argument :locked, GraphQL::Types::Boolean, + required: false, + description: 'Indicates the runner is locked.' + + argument :run_untagged, GraphQL::Types::Boolean, + required: false, + description: 'Indicates the runner is able to run untagged jobs.' + + argument :tag_list, [GraphQL::Types::String], + required: false, + description: 'Tags associated with the runner.' + + argument :associated_projects, [::Types::GlobalIDType[::Project]], + required: false, + description: 'Projects associated with the runner. Available only for project runners.', + prepare: ->(global_ids, _ctx) { global_ids&.filter_map { |gid| gid.model_id.to_i } } + end + end + end + end +end diff --git a/app/graphql/mutations/ci/runner/create.rb b/app/graphql/mutations/ci/runner/create.rb new file mode 100644 index 00000000000..1cdee560ca8 --- /dev/null +++ b/app/graphql/mutations/ci/runner/create.rb @@ -0,0 +1,44 @@ +# frozen_string_literal: true + +module Mutations + module Ci + module Runner + class Create < BaseMutation + graphql_name 'RunnerCreate' + + authorize :create_runner + + include Mutations::Ci::Runner::CommonMutationArguments + + field :runner, + Types::Ci::RunnerType, + null: true, + description: 'Runner after mutation.' + + def resolve(**args) + if Feature.disabled?(:create_runner_workflow) + raise Gitlab::Graphql::Errors::ResourceNotAvailable, + '`create_runner_workflow` feature flag is disabled.' + end + + create_runner(args) + end + + private + + def create_runner(params) + response = { runner: nil, errors: [] } + result = ::Ci::Runners::CreateRunnerService.new(user: current_user, type: nil, params: params).execute + + if result.success? + response[:runner] = result.payload[:runner] + else + response[:errors] = result.errors + end + + response + end + end + end + end +end diff --git a/app/graphql/mutations/ci/runner/update.rb b/app/graphql/mutations/ci/runner/update.rb index 4f0bf19f09c..70f08e03553 100644 --- a/app/graphql/mutations/ci/runner/update.rb +++ b/app/graphql/mutations/ci/runner/update.rb @@ -8,54 +8,19 @@ module Mutations authorize :update_runner + include Mutations::Ci::Runner::CommonMutationArguments + RunnerID = ::Types::GlobalIDType[::Ci::Runner] argument :id, RunnerID, required: true, description: 'ID of the runner to update.' - argument :description, GraphQL::Types::String, - required: false, - description: 'Description of the runner.' - - argument :maintenance_note, GraphQL::Types::String, - required: false, - description: 'Runner\'s maintenance notes.' - - argument :maximum_timeout, GraphQL::Types::Int, - 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::Types::Boolean, required: false, description: 'Indicates the runner is allowed to receive jobs.', deprecated: { reason: :renamed, replacement: 'paused', milestone: '14.8' } - argument :paused, GraphQL::Types::Boolean, - required: false, - description: 'Indicates the runner is not allowed to receive jobs.' - - argument :locked, GraphQL::Types::Boolean, - required: false, - description: 'Indicates the runner is locked.' - - argument :run_untagged, GraphQL::Types::Boolean, - required: false, - description: 'Indicates the runner is able to run untagged jobs.' - - argument :tag_list, [GraphQL::Types::String], - required: false, - description: 'Tags associated with the runner.' - - argument :associated_projects, [::Types::GlobalIDType[::Project]], - required: false, - description: 'Projects associated with the runner. Available only for project runners.', - prepare: ->(global_ids, ctx) { global_ids&.filter_map { |gid| gid.model_id.to_i } } - field :runner, Types::Ci::RunnerType, null: true, |