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:
Diffstat (limited to 'app/services/ci/runners/assign_runner_service.rb')
-rw-r--r--app/services/ci/runners/assign_runner_service.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/app/services/ci/runners/assign_runner_service.rb b/app/services/ci/runners/assign_runner_service.rb
new file mode 100644
index 00000000000..886cd3a4e44
--- /dev/null
+++ b/app/services/ci/runners/assign_runner_service.rb
@@ -0,0 +1,28 @@
+# frozen_string_literal: true
+
+module Ci
+ module Runners
+ class AssignRunnerService
+ # @param [Ci::Runner] runner: the runner to assign to a project
+ # @param [Project] project: the new project to assign the runner to
+ # @param [User] user: the user performing the operation
+ def initialize(runner, project, user)
+ @runner = runner
+ @project = project
+ @user = user
+ end
+
+ def execute
+ return false unless @user.present? && @user.can?(:assign_runner, @runner)
+
+ @runner.assign_to(@project, @user)
+ end
+
+ private
+
+ attr_reader :runner, :project, :user
+ end
+ end
+end
+
+Ci::Runners::AssignRunnerService.prepend_mod