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

assign_runner_service.rb « runners « ci « services « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 886cd3a4e44120c0222f65f4e87b103679a4ccf3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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