gitlab-org--gitlab-foss/app/controllers/projects/runners_controller.rb

65 lines
1.5 KiB
Ruby
Raw Normal View History

class Projects::RunnersController < Projects::ApplicationController
before_action :authorize_admin_build!
before_action :set_runner, only: [:edit, :update, :destroy, :pause, :resume, :show]
layout 'project_settings'
def index
redirect_to project_settings_ci_cd_path(@project)
end
def edit
end
def update
if Ci::UpdateRunnerService.new(@runner).update(runner_params)
redirect_to runner_path(@runner), notice: 'Runner was successfully updated.'
else
2016-05-05 08:27:06 -04:00
render 'edit'
end
end
def destroy
2015-12-04 06:55:23 -05:00
if @runner.only_for?(project)
@runner.destroy
end
redirect_to runners_path(@project), status: 302
end
def resume
if Ci::UpdateRunnerService.new(@runner).update(active: true)
redirect_to runners_path(@project), notice: 'Runner was successfully updated.'
else
redirect_to runners_path(@project), alert: 'Runner was not updated.'
end
end
def pause
if Ci::UpdateRunnerService.new(@runner).update(active: false)
redirect_to runners_path(@project), notice: 'Runner was successfully updated.'
else
redirect_to runners_path(@project), 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)
redirect_to project_settings_ci_cd_path(@project)
2015-12-04 06:55:23 -05:00
end
protected
def set_runner
@runner ||= project.runners.find(params[:id])
end
def runner_params
params.require(:runner).permit(Ci::Runner::FORM_EDITABLE)
end
end