gitlab-org--gitlab-foss/app/controllers/admin/runner_projects_controller.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

37 lines
1 KiB
Ruby
Raw Permalink Normal View History

# frozen_string_literal: true
2015-12-04 06:55:23 -05:00
class Admin::RunnerProjectsController < Admin::ApplicationController
before_action :project, only: [:create]
feature_category :runner
urgency :low
2015-12-04 06:55:23 -05:00
def create
@runner = Ci::Runner.find(params[:runner_project][:runner_id])
if ::Ci::Runners::AssignRunnerService.new(@runner, @project, current_user).execute.success?
redirect_to edit_admin_runner_url(@runner), notice: s_('Runners|Runner assigned to project.')
2015-12-04 06:55:23 -05:00
else
redirect_to edit_admin_runner_url(@runner), alert: 'Failed adding runner to project'
2015-12-04 06:55:23 -05:00
end
end
def destroy
rp = Ci::RunnerProject.find(params[:id])
runner = rp.runner
::Ci::Runners::UnassignRunnerService.new(rp, current_user).execute
2015-12-04 06:55:23 -05:00
redirect_to edit_admin_runner_url(runner), status: :found, notice: s_('Runners|Runner unassigned from project.')
2015-12-04 06:55:23 -05:00
end
private
def project
@project = Project.find_by_full_path(
2015-12-04 06:55:23 -05:00
[params[:namespace_id], '/', params[:project_id]].join('')
)
@project || render_404
end
end