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-01-23 19:51:16 -05:00
|
|
|
redirect_to namespace_project_settings_ci_cd_path(@project.namespace, @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
|
|
|
|
|
|
|
|
redirect_to runners_path(@project)
|
|
|
|
end
|
|
|
|
|
|
|
|
def resume
|
2017-01-20 08:57:01 -05:00
|
|
|
if Ci::UpdateRunnerService.new(@runner).update(active: true)
|
2015-09-25 12:03:41 -04:00
|
|
|
redirect_to runner_path(@runner), notice: 'Runner was successfully updated.'
|
|
|
|
else
|
|
|
|
redirect_to runner_path(@runner), alert: 'Runner was not updated.'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def pause
|
2017-01-20 08:57:01 -05:00
|
|
|
if Ci::UpdateRunnerService.new(@runner).update(active: false)
|
2015-09-25 12:03:41 -04:00
|
|
|
redirect_to runner_path(@runner), notice: 'Runner was successfully updated.'
|
|
|
|
else
|
|
|
|
redirect_to runner_path(@runner), alert: 'Runner was not updated.'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def show
|
|
|
|
end
|
|
|
|
|
2015-12-04 06:55:23 -05:00
|
|
|
def toggle_shared_runners
|
|
|
|
project.toggle!(:shared_runners_enabled)
|
|
|
|
|
2017-01-23 17:19:39 -05:00
|
|
|
redirect_to namespace_project_settings_ci_cd_path(@project.namespace, @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
|