2015-09-25 12:03:41 -04:00
|
|
|
class Projects::RunnersController < Projects::ApplicationController
|
2016-02-01 17:58:04 -05:00
|
|
|
before_action :authorize_admin_build!
|
2015-09-25 12:03:41 -04:00
|
|
|
before_action :set_runner, only: [:edit, :update, :destroy, :pause, :resume, :show]
|
|
|
|
|
|
|
|
layout 'project_settings'
|
|
|
|
|
|
|
|
def index
|
2017-06-29 13:06:35 -04:00
|
|
|
redirect_to project_settings_ci_cd_path(@project)
|
2015-09-25 12:03:41 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def edit
|
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
2017-01-20 08:57:01 -05:00
|
|
|
if Ci::UpdateRunnerService.new(@runner).update(runner_params)
|
2015-09-25 12:03:41 -04:00
|
|
|
redirect_to runner_path(@runner), notice: 'Runner was successfully updated.'
|
|
|
|
else
|
2016-05-05 08:27:06 -04:00
|
|
|
render 'edit'
|
2015-09-25 12:03:41 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
2015-12-04 06:55:23 -05:00
|
|
|
if @runner.only_for?(project)
|
2015-09-25 12:03:41 -04:00
|
|
|
@runner.destroy
|
|
|
|
end
|
|
|
|
|
2017-06-06 18:45:16 -04:00
|
|
|
redirect_to runners_path(@project), status: 302
|
2015-09-25 12:03:41 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def resume
|
2017-01-20 08:57:01 -05:00
|
|
|
if Ci::UpdateRunnerService.new(@runner).update(active: true)
|
2017-12-19 16:24:36 -05:00
|
|
|
redirect_to runners_path(@project), notice: 'Runner was successfully updated.'
|
2015-09-25 12:03:41 -04:00
|
|
|
else
|
2017-12-19 16:24:36 -05:00
|
|
|
redirect_to runners_path(@project), alert: 'Runner was not updated.'
|
2015-09-25 12:03:41 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def pause
|
2017-01-20 08:57:01 -05:00
|
|
|
if Ci::UpdateRunnerService.new(@runner).update(active: false)
|
2017-12-19 16:24:36 -05:00
|
|
|
redirect_to runners_path(@project), notice: 'Runner was successfully updated.'
|
2015-09-25 12:03:41 -04:00
|
|
|
else
|
2017-12-19 16:24:36 -05:00
|
|
|
redirect_to runners_path(@project), alert: 'Runner was not updated.'
|
2015-09-25 12:03:41 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def show
|
|
|
|
end
|
|
|
|
|
2015-12-04 06:55:23 -05:00
|
|
|
def toggle_shared_runners
|
|
|
|
project.toggle!(:shared_runners_enabled)
|
|
|
|
|
2017-06-29 13:06:35 -04:00
|
|
|
redirect_to project_settings_ci_cd_path(@project)
|
2015-12-04 06:55:23 -05:00
|
|
|
end
|
|
|
|
|
2015-09-25 12:03:41 -04:00
|
|
|
protected
|
|
|
|
|
|
|
|
def set_runner
|
2015-12-10 11:44:06 -05:00
|
|
|
@runner ||= project.runners.find(params[:id])
|
2015-09-25 12:03:41 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
def runner_params
|
2016-05-09 07:07:10 -04:00
|
|
|
params.require(:runner).permit(Ci::Runner::FORM_EDITABLE)
|
2015-09-25 12:03:41 -04:00
|
|
|
end
|
|
|
|
end
|