BigW Consortium Gitlab

runner_projects_controller.rb 693 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
    return head(403) unless can?(current_user, :assign_runner, @runner)
10 11

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

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

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

    redirect_to runners_path(project)
  end
end