2018-12-05 23:21:45 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-10-15 14:42:47 +05:30
|
|
|
class Groups::RunnersController < Groups::ApplicationController
|
2022-03-02 08:16:31 +05:30
|
|
|
before_action :authorize_read_group_runners!, only: [:index, :show]
|
2022-11-25 23:54:43 +05:30
|
|
|
before_action :authorize_update_runner!, only: [:edit, :update, :destroy, :pause, :resume]
|
2018-10-15 14:42:47 +05:30
|
|
|
before_action :runner, only: [:edit, :update, :destroy, :pause, :resume, :show]
|
|
|
|
|
2021-09-30 23:02:18 +05:30
|
|
|
feature_category :runner
|
2022-07-16 23:28:13 +05:30
|
|
|
urgency :low
|
2021-01-03 14:25:43 +05:30
|
|
|
|
2021-10-27 15:23:28 +05:30
|
|
|
def index
|
2022-04-04 11:22:00 +05:30
|
|
|
finder = Ci::RunnersFinder.new(current_user: current_user, params: { group: @group })
|
|
|
|
@group_runners_limited_count = finder.execute.except(:limit, :offset).page.total_count_with_limit(:all, limit: 1000)
|
2022-10-11 01:57:18 +05:30
|
|
|
@group_runner_registration_token = @group.runners_token if can?(current_user, :register_group_runners, group)
|
2022-06-21 17:19:12 +05:30
|
|
|
|
|
|
|
Gitlab::Tracking.event(self.class.name, 'index', user: current_user, namespace: @group)
|
2021-10-27 15:23:28 +05:30
|
|
|
end
|
|
|
|
|
2018-10-15 14:42:47 +05:30
|
|
|
def show
|
|
|
|
end
|
|
|
|
|
|
|
|
def edit
|
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
2022-10-11 01:57:18 +05:30
|
|
|
if Ci::Runners::UpdateRunnerService.new(@runner).execute(runner_params).success?
|
2019-07-07 11:18:12 +05:30
|
|
|
redirect_to group_runner_path(@group, @runner), notice: _('Runner was successfully updated.')
|
2018-10-15 14:42:47 +05:30
|
|
|
else
|
|
|
|
render 'edit'
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def runner
|
2022-11-25 23:54:43 +05:30
|
|
|
group_params = { group: @group, membership: :all_available }
|
|
|
|
|
|
|
|
@runner ||= Ci::RunnersFinder.new(current_user: current_user, params: group_params).execute
|
2022-04-04 11:22:00 +05:30
|
|
|
.except(:limit, :offset)
|
|
|
|
.find(params[:id])
|
2018-10-15 14:42:47 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def runner_params
|
|
|
|
params.require(:runner).permit(Ci::Runner::FORM_EDITABLE)
|
|
|
|
end
|
2022-11-25 23:54:43 +05:30
|
|
|
|
|
|
|
def authorize_update_runner!
|
|
|
|
return if can?(current_user, :admin_group_runners, group) && can?(current_user, :update_runner, runner)
|
|
|
|
|
|
|
|
render_404
|
|
|
|
end
|
2018-10-15 14:42:47 +05:30
|
|
|
end
|
2022-07-23 23:45:48 +05:30
|
|
|
|
|
|
|
Groups::RunnersController.prepend_mod
|