BigW Consortium Gitlab

runner_projects_controller.rb 764 Bytes
Newer Older
1
class Projects::RunnerProjectsController < Projects::ApplicationController
2
  before_action :authorize_admin_build!
3 4 5 6 7 8

  layout 'project_settings'

  def create
    @runner = Ci::Runner.find(params[:runner_project][:runner_id])

9 10
    return head(409) if @runner.is_shared? || @runner.locked?
    return head(409) unless current_user.ci_authorized_runners.include?(@runner)
11 12

    path = runners_path(project)
13
    runner_project = @runner.assign_to(project, current_user)
14

15
    if runner_project.persisted?
16 17 18 19 20 21 22
      redirect_to path
    else
      redirect_to path, alert: 'Failed adding runner to project'
    end
  end

  def destroy
23
    runner_project = project.runner_projects.find(params[:id])
24 25 26 27 28
    runner_project.destroy

    redirect_to runners_path(project)
  end
end