2018-12-05 23:21:45 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-12-23 02:04:40 +05:30
|
|
|
class Admin::RunnersController < Admin::ApplicationController
|
2021-01-03 14:25:43 +05:30
|
|
|
include RunnerSetupScripts
|
|
|
|
|
2023-04-23 21:23:45 +05:30
|
|
|
before_action :runner, except: [:index, :new, :tag_list, :runner_setup_scripts]
|
|
|
|
|
|
|
|
before_action only: [:index] do
|
2023-05-27 22:25:52 +05:30
|
|
|
push_frontend_feature_flag(:create_runner_workflow_for_admin, current_user)
|
2023-04-23 21:23:45 +05:30
|
|
|
end
|
2022-10-11 01:57:18 +05:30
|
|
|
|
2021-09-30 23:02:18 +05:30
|
|
|
feature_category :runner
|
2022-07-16 23:28:13 +05:30
|
|
|
urgency :low
|
2015-12-23 02:04:40 +05:30
|
|
|
|
|
|
|
def index
|
|
|
|
end
|
|
|
|
|
|
|
|
def show
|
2022-03-02 08:16:31 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
def edit
|
2022-07-16 23:28:13 +05:30
|
|
|
assign_projects
|
2015-12-23 02:04:40 +05:30
|
|
|
end
|
|
|
|
|
2023-04-23 21:23:45 +05:30
|
|
|
def new
|
2023-05-27 22:25:52 +05:30
|
|
|
render_404 unless Feature.enabled?(:create_runner_workflow_for_admin, current_user)
|
|
|
|
end
|
|
|
|
|
|
|
|
def register
|
|
|
|
render_404 unless Feature.enabled?(:create_runner_workflow_for_admin, current_user) &&
|
|
|
|
runner.registration_available?
|
2023-04-23 21:23:45 +05:30
|
|
|
end
|
|
|
|
|
2015-12-23 02:04:40 +05:30
|
|
|
def update
|
2022-10-11 01:57:18 +05:30
|
|
|
if Ci::Runners::UpdateRunnerService.new(@runner).execute(runner_params).success?
|
2016-06-02 11:05:42 +05:30
|
|
|
respond_to do |format|
|
2022-03-02 08:16:31 +05:30
|
|
|
format.html { redirect_to edit_admin_runner_path(@runner) }
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|
|
|
|
else
|
2022-07-16 23:28:13 +05:30
|
|
|
assign_projects
|
2016-06-02 11:05:42 +05:30
|
|
|
render 'show'
|
2015-12-23 02:04:40 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2019-07-07 11:18:12 +05:30
|
|
|
def tag_list
|
|
|
|
tags = Autocomplete::ActsAsTaggableOn::TagsFinder.new(params: params).execute
|
|
|
|
|
|
|
|
render json: ActsAsTaggableOn::TagSerializer.new.represent(tags)
|
|
|
|
end
|
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
def runner_setup_scripts
|
|
|
|
private_runner_setup_scripts
|
|
|
|
end
|
|
|
|
|
2015-12-23 02:04:40 +05:30
|
|
|
private
|
|
|
|
|
|
|
|
def runner
|
|
|
|
@runner ||= Ci::Runner.find(params[:id])
|
|
|
|
end
|
|
|
|
|
|
|
|
def runner_params
|
2020-04-22 19:07:51 +05:30
|
|
|
params.require(:runner).permit(permitted_attrs)
|
|
|
|
end
|
|
|
|
|
|
|
|
def permitted_attrs
|
|
|
|
if Gitlab.com?
|
|
|
|
Ci::Runner::FORM_EDITABLE + Ci::Runner::MINUTES_COST_FACTOR_FIELDS
|
|
|
|
else
|
|
|
|
Ci::Runner::FORM_EDITABLE
|
|
|
|
end
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|
|
|
|
|
2018-12-05 23:21:45 +05:30
|
|
|
# rubocop: disable CodeReuse/ActiveRecord
|
2022-07-16 23:28:13 +05:30
|
|
|
def assign_projects
|
2016-06-02 11:05:42 +05:30
|
|
|
@projects =
|
|
|
|
if params[:search].present?
|
|
|
|
::Project.search(params[:search])
|
|
|
|
else
|
|
|
|
Project.all
|
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2022-04-04 11:22:00 +05:30
|
|
|
runner_projects_ids = runner.runner_projects.pluck(:project_id)
|
|
|
|
@projects = @projects.where.not(id: runner_projects_ids) if runner_projects_ids.any?
|
|
|
|
@projects = @projects.inc_routes
|
|
|
|
@projects = @projects.page(params[:page]).per(30).without_count
|
2015-12-23 02:04:40 +05:30
|
|
|
end
|
2018-12-05 23:21:45 +05:30
|
|
|
# rubocop: enable CodeReuse/ActiveRecord
|
2015-12-23 02:04:40 +05:30
|
|
|
end
|
2022-07-23 23:45:48 +05:30
|
|
|
|
|
|
|
Admin::RunnersController.prepend_mod
|