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

65 lines
1.5 KiB
Ruby
Raw Normal View History

2015-10-24 18:46:33 +05:30
class Projects::RunnersController < Projects::ApplicationController
2016-04-02 18:10:28 +05:30
before_action :authorize_admin_build!
2015-10-24 18:46:33 +05:30
before_action :set_runner, only: [:edit, :update, :destroy, :pause, :resume, :show]
layout 'project_settings'
def index
2017-09-10 17:25:29 +05:30
redirect_to project_settings_ci_cd_path(@project)
2015-10-24 18:46:33 +05:30
end
def edit
end
def update
2017-08-17 22:00:37 +05:30
if Ci::UpdateRunnerService.new(@runner).update(runner_params)
2015-10-24 18:46:33 +05:30
redirect_to runner_path(@runner), notice: 'Runner was successfully updated.'
else
2016-06-02 11:05:42 +05:30
render 'edit'
2015-10-24 18:46:33 +05:30
end
end
def destroy
2015-12-23 02:04:40 +05:30
if @runner.only_for?(project)
2015-10-24 18:46:33 +05:30
@runner.destroy
end
2017-09-10 17:25:29 +05:30
redirect_to runners_path(@project), status: 302
2015-10-24 18:46:33 +05:30
end
def resume
2017-08-17 22:00:37 +05:30
if Ci::UpdateRunnerService.new(@runner).update(active: true)
2018-03-17 18:26:18 +05:30
redirect_to runners_path(@project), notice: 'Runner was successfully updated.'
2015-10-24 18:46:33 +05:30
else
2018-03-17 18:26:18 +05:30
redirect_to runners_path(@project), alert: 'Runner was not updated.'
2015-10-24 18:46:33 +05:30
end
end
def pause
2017-08-17 22:00:37 +05:30
if Ci::UpdateRunnerService.new(@runner).update(active: false)
2018-03-17 18:26:18 +05:30
redirect_to runners_path(@project), notice: 'Runner was successfully updated.'
2015-10-24 18:46:33 +05:30
else
2018-03-17 18:26:18 +05:30
redirect_to runners_path(@project), alert: 'Runner was not updated.'
2015-10-24 18:46:33 +05:30
end
end
def show
end
2015-12-23 02:04:40 +05:30
def toggle_shared_runners
project.toggle!(:shared_runners_enabled)
2017-09-10 17:25:29 +05:30
redirect_to project_settings_ci_cd_path(@project)
2015-12-23 02:04:40 +05:30
end
2015-10-24 18:46:33 +05:30
protected
def set_runner
2015-12-23 02:04:40 +05:30
@runner ||= project.runners.find(params[:id])
2015-10-24 18:46:33 +05:30
end
def runner_params
2016-06-02 11:05:42 +05:30
params.require(:runner).permit(Ci::Runner::FORM_EDITABLE)
2015-10-24 18:46:33 +05:30
end
end