debian-mirror-gitlab/app/controllers/admin/runner_projects_controller.rb

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

39 lines
1 KiB
Ruby
Raw Normal View History

2018-12-05 23:21:45 +05:30
# frozen_string_literal: true
2015-12-23 02:04:40 +05:30
class Admin::RunnerProjectsController < Admin::ApplicationController
before_action :project, only: [:create]
2021-10-27 15:23:28 +05:30
feature_category :runner
2022-07-16 23:28:13 +05:30
urgency :low
2021-01-03 14:25:43 +05:30
2015-12-23 02:04:40 +05:30
def create
@runner = Ci::Runner.find(params[:runner_project][:runner_id])
2022-08-27 11:52:29 +05:30
if ::Ci::Runners::AssignRunnerService.new(@runner, @project, current_user).execute.success?
2023-07-09 08:55:56 +05:30
flash[:success] = s_('Runners|Runner assigned to project.')
redirect_to edit_admin_runner_url(@runner)
2015-12-23 02:04:40 +05:30
else
2023-07-09 08:55:56 +05:30
redirect_to edit_admin_runner_url(@runner), alert: s_('Runners|Failed adding runner to project')
2015-12-23 02:04:40 +05:30
end
end
def destroy
rp = Ci::RunnerProject.find(params[:id])
runner = rp.runner
2022-05-07 20:08:51 +05:30
::Ci::Runners::UnassignRunnerService.new(rp, current_user).execute
2015-12-23 02:04:40 +05:30
2023-07-09 08:55:56 +05:30
flash[:success] = s_('Runners|Runner unassigned from project.')
redirect_to edit_admin_runner_url(runner), status: :found
2015-12-23 02:04:40 +05:30
end
private
def project
2017-08-17 22:00:37 +05:30
@project = Project.find_by_full_path(
2015-12-23 02:04:40 +05:30
[params[:namespace_id], '/', params[:project_id]].join('')
)
@project || render_404
end
end