debian-mirror-gitlab/app/controllers/groups/runners_controller.rb

65 lines
2.1 KiB
Ruby
Raw Normal View History

2018-12-05 23:21:45 +05:30
# frozen_string_literal: true
2018-10-15 14:42:47 +05:30
class Groups::RunnersController < Groups::ApplicationController
# Proper policies should be implemented per
2019-12-04 20:38:33 +05:30
# https://gitlab.com/gitlab-org/gitlab-foss/issues/45894
2019-09-04 21:01:54 +05:30
before_action :authorize_admin_group!
2018-10-15 14:42:47 +05:30
before_action :runner, only: [:edit, :update, :destroy, :pause, :resume, :show]
2021-01-03 14:25:43 +05:30
feature_category :continuous_integration
2018-10-15 14:42:47 +05:30
def show
render 'shared/runners/show'
end
def edit
end
def update
if Ci::UpdateRunnerService.new(@runner).update(runner_params)
2019-07-07 11:18:12 +05:30
redirect_to group_runner_path(@group, @runner), notice: _('Runner was successfully updated.')
2018-10-15 14:42:47 +05:30
else
render 'edit'
end
end
def destroy
2020-07-28 23:09:34 +05:30
if @runner.belongs_to_more_than_one_project?
redirect_to group_settings_ci_cd_path(@group, anchor: 'runners-settings'), status: :found, alert: _('Runner was not deleted because it is assigned to multiple projects.')
else
@runner.destroy
2018-10-15 14:42:47 +05:30
2020-07-28 23:09:34 +05:30
redirect_to group_settings_ci_cd_path(@group, anchor: 'runners-settings'), status: :found
end
2018-10-15 14:42:47 +05:30
end
def resume
if Ci::UpdateRunnerService.new(@runner).update(active: true)
2019-07-07 11:18:12 +05:30
redirect_to group_settings_ci_cd_path(@group, anchor: 'runners-settings'), notice: _('Runner was successfully updated.')
2018-10-15 14:42:47 +05:30
else
2019-07-07 11:18:12 +05:30
redirect_to group_settings_ci_cd_path(@group, anchor: 'runners-settings'), alert: _('Runner was not updated.')
2018-10-15 14:42:47 +05:30
end
end
def pause
if Ci::UpdateRunnerService.new(@runner).update(active: false)
2019-07-07 11:18:12 +05:30
redirect_to group_settings_ci_cd_path(@group, anchor: 'runners-settings'), notice: _('Runner was successfully updated.')
2018-10-15 14:42:47 +05:30
else
2019-07-07 11:18:12 +05:30
redirect_to group_settings_ci_cd_path(@group, anchor: 'runners-settings'), alert: _('Runner was not updated.')
2018-10-15 14:42:47 +05:30
end
end
private
def runner
2020-07-28 23:09:34 +05:30
@runner ||= Ci::RunnersFinder.new(current_user: current_user, group: @group, params: {}).execute
.except(:limit, :offset)
.find(params[:id])
2018-10-15 14:42:47 +05:30
end
def runner_params
params.require(:runner).permit(Ci::Runner::FORM_EDITABLE)
end
end