2018-09-23 15:44:14 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-04-10 00:29:06 -04:00
|
|
|
class Groups::RunnersController < Groups::ApplicationController
|
2018-05-07 02:56:59 -04:00
|
|
|
# Proper policies should be implemented per
|
|
|
|
# https://gitlab.com/gitlab-org/gitlab-ce/issues/45894
|
2018-04-10 00:29:06 -04:00
|
|
|
before_action :authorize_admin_pipeline!
|
2018-05-07 02:56:59 -04:00
|
|
|
|
2018-05-04 08:02:37 -04:00
|
|
|
before_action :runner, only: [:edit, :update, :destroy, :pause, :resume, :show]
|
2018-04-10 00:29:06 -04:00
|
|
|
|
|
|
|
def show
|
2018-05-04 07:59:19 -04:00
|
|
|
render 'shared/runners/show'
|
2018-04-10 00:29:06 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def edit
|
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
|
|
|
if Ci::UpdateRunnerService.new(@runner).update(runner_params)
|
2019-03-27 12:52:52 -04:00
|
|
|
redirect_to group_runner_path(@group, @runner), notice: _('Runner was successfully updated.')
|
2018-04-10 00:29:06 -04:00
|
|
|
else
|
|
|
|
render 'edit'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
@runner.destroy
|
|
|
|
|
2018-07-02 06:43:06 -04:00
|
|
|
redirect_to group_settings_ci_cd_path(@group, anchor: 'runners-settings'), status: :found
|
2018-04-10 00:29:06 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def resume
|
|
|
|
if Ci::UpdateRunnerService.new(@runner).update(active: true)
|
2019-03-27 12:52:52 -04:00
|
|
|
redirect_to group_settings_ci_cd_path(@group, anchor: 'runners-settings'), notice: _('Runner was successfully updated.')
|
2018-04-10 00:29:06 -04:00
|
|
|
else
|
2019-03-27 12:52:52 -04:00
|
|
|
redirect_to group_settings_ci_cd_path(@group, anchor: 'runners-settings'), alert: _('Runner was not updated.')
|
2018-04-10 00:29:06 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def pause
|
|
|
|
if Ci::UpdateRunnerService.new(@runner).update(active: false)
|
2019-03-27 12:52:52 -04:00
|
|
|
redirect_to group_settings_ci_cd_path(@group, anchor: 'runners-settings'), notice: _('Runner was successfully updated.')
|
2018-04-10 00:29:06 -04:00
|
|
|
else
|
2019-03-27 12:52:52 -04:00
|
|
|
redirect_to group_settings_ci_cd_path(@group, anchor: 'runners-settings'), alert: _('Runner was not updated.')
|
2018-04-10 00:29:06 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2018-05-04 08:02:37 -04:00
|
|
|
def runner
|
2018-04-10 00:29:06 -04:00
|
|
|
@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
|