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]
|
2023-06-20 00:43:36 +05:30
|
|
|
before_action :authorize_create_group_runners!, only: [:new, :register]
|
2022-11-25 23:54:43 +05:30
|
|
|
before_action :authorize_update_runner!, only: [:edit, :update, :destroy, :pause, :resume]
|
2023-06-20 00:43:36 +05:30
|
|
|
before_action :runner, only: [:edit, :update, :destroy, :pause, :resume, :show, :register]
|
|
|
|
|
|
|
|
before_action only: [:index] do
|
|
|
|
push_frontend_feature_flag(:create_runner_workflow_for_namespace, group)
|
|
|
|
end
|
2018-10-15 14:42:47 +05:30
|
|
|
|
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-10-11 01:57:18 +05:30
|
|
|
@group_runner_registration_token = @group.runners_token if can?(current_user, :register_group_runners, group)
|
2023-06-20 00:43:36 +05:30
|
|
|
@group_new_runner_path = new_group_runner_path(@group) if can?(current_user, :create_runner, 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
|
|
|
|
|
2023-06-20 00:43:36 +05:30
|
|
|
def new
|
|
|
|
render_404 unless create_runner_workflow_for_namespace_enabled?
|
|
|
|
end
|
|
|
|
|
|
|
|
def register
|
|
|
|
render_404 unless create_runner_workflow_for_namespace_enabled? && runner.registration_available?
|
|
|
|
end
|
|
|
|
|
2018-10-15 14:42:47 +05:30
|
|
|
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
|
2023-06-20 00:43:36 +05:30
|
|
|
|
|
|
|
def authorize_create_group_runners!
|
|
|
|
return if can?(current_user, :create_runner, group)
|
|
|
|
|
|
|
|
render_404
|
|
|
|
end
|
|
|
|
|
|
|
|
def create_runner_workflow_for_namespace_enabled?
|
|
|
|
Feature.enabled?(:create_runner_workflow_for_namespace, group)
|
|
|
|
end
|
2018-10-15 14:42:47 +05:30
|
|
|
end
|
2022-07-23 23:45:48 +05:30
|
|
|
|
|
|
|
Groups::RunnersController.prepend_mod
|