Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/groups/runners_controller.rb')
-rw-r--r--app/controllers/groups/runners_controller.rb58
1 files changed, 58 insertions, 0 deletions
diff --git a/app/controllers/groups/runners_controller.rb b/app/controllers/groups/runners_controller.rb
new file mode 100644
index 00000000000..78992ec7f46
--- /dev/null
+++ b/app/controllers/groups/runners_controller.rb
@@ -0,0 +1,58 @@
+class Groups::RunnersController < Groups::ApplicationController
+ # Proper policies should be implemented per
+ # https://gitlab.com/gitlab-org/gitlab-ce/issues/45894
+ before_action :authorize_admin_pipeline!
+
+ before_action :runner, only: [:edit, :update, :destroy, :pause, :resume, :show]
+
+ def show
+ render 'shared/runners/show'
+ end
+
+ def edit
+ end
+
+ def update
+ if Ci::UpdateRunnerService.new(@runner).update(runner_params)
+ redirect_to group_runner_path(@group, @runner), notice: 'Runner was successfully updated.'
+ else
+ render 'edit'
+ end
+ end
+
+ def destroy
+ @runner.destroy
+
+ redirect_to group_settings_ci_cd_path(@group, anchor: 'runners-settings'), status: 302
+ end
+
+ def resume
+ if Ci::UpdateRunnerService.new(@runner).update(active: true)
+ redirect_to group_settings_ci_cd_path(@group, anchor: 'runners-settings'), notice: 'Runner was successfully updated.'
+ else
+ redirect_to group_settings_ci_cd_path(@group, anchor: 'runners-settings'), alert: 'Runner was not updated.'
+ end
+ end
+
+ def pause
+ if Ci::UpdateRunnerService.new(@runner).update(active: false)
+ redirect_to group_settings_ci_cd_path(@group, anchor: 'runners-settings'), notice: 'Runner was successfully updated.'
+ else
+ redirect_to group_settings_ci_cd_path(@group, anchor: 'runners-settings'), alert: 'Runner was not updated.'
+ end
+ end
+
+ private
+
+ def runner
+ @runner ||= @group.runners.find(params[:id])
+ end
+
+ def authorize_admin_pipeline!
+ return render_404 unless can?(current_user, :admin_pipeline, group)
+ end
+
+ def runner_params
+ params.require(:runner).permit(Ci::Runner::FORM_EDITABLE)
+ end
+end