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

61 lines
1.7 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
# https://gitlab.com/gitlab-org/gitlab-ce/issues/45894
before_action :authorize_admin_pipeline!
before_action :runner, only: [:edit, :update, :destroy, :pause, :resume, :show]
def show
render 'shared/runners/show'
end
def edit
end
def update
if Ci::UpdateRunnerService.new(@runner).update(runner_params)
2019-05-18 00:54:41 +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
@runner.destroy
2018-11-18 11:00:15 +05:30
redirect_to group_settings_ci_cd_path(@group, anchor: 'runners-settings'), status: :found
2018-10-15 14:42:47 +05:30
end
def resume
if Ci::UpdateRunnerService.new(@runner).update(active: true)
2019-05-18 00:54:41 +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-05-18 00:54:41 +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-05-18 00:54:41 +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-05-18 00:54:41 +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
@runner ||= @group.runners.find(params[:id])
end
def authorize_admin_pipeline!
return render_404 unless can?(current_user, :admin_pipeline, group)
end
def runner_params
params.require(:runner).permit(Ci::Runner::FORM_EDITABLE)
end
end