2018-09-23 15:44:14 -04:00
# frozen_string_literal: true
2018-04-10 00:29:06 -04:00
class Groups :: RunnersController < Groups :: ApplicationController
2018-05-07 02:56:59 -04:00
# Proper policies should be implemented per
2019-09-18 10:02:45 -04:00
# https://gitlab.com/gitlab-org/gitlab-foss/issues/45894
2019-08-13 19:03:05 -04:00
before_action :authorize_admin_group!
2018-05-07 02:56:59 -04:00
2018-05-04 08:02:37 -04:00
before_action :runner , only : [ :edit , :update , :destroy , :pause , :resume , :show ]
2018-04-10 00:29:06 -04:00
2021-06-21 11:07:30 -04:00
feature_category :runner
2020-10-06 08:08:38 -04:00
2018-04-10 00:29:06 -04:00
def show
end
def edit
end
def update
if Ci :: UpdateRunnerService . new ( @runner ) . update ( runner_params )
2019-03-27 12:52:52 -04:00
redirect_to group_runner_path ( @group , @runner ) , notice : _ ( 'Runner was successfully updated.' )
2018-04-10 00:29:06 -04:00
else
render 'edit'
end
end
def destroy
2020-07-17 05:09:43 -04:00
if @runner . belongs_to_more_than_one_project?
redirect_to group_settings_ci_cd_path ( @group , anchor : 'runners-settings' ) , status : :found , alert : _ ( 'Runner was not deleted because it is assigned to multiple projects.' )
else
@runner . destroy
2018-04-10 00:29:06 -04:00
2020-07-17 05:09:43 -04:00
redirect_to group_settings_ci_cd_path ( @group , anchor : 'runners-settings' ) , status : :found
end
2018-04-10 00:29:06 -04:00
end
def resume
if Ci :: UpdateRunnerService . new ( @runner ) . update ( active : true )
2019-03-27 12:52:52 -04:00
redirect_to group_settings_ci_cd_path ( @group , anchor : 'runners-settings' ) , notice : _ ( 'Runner was successfully updated.' )
2018-04-10 00:29:06 -04:00
else
2019-03-27 12:52:52 -04:00
redirect_to group_settings_ci_cd_path ( @group , anchor : 'runners-settings' ) , alert : _ ( 'Runner was not updated.' )
2018-04-10 00:29:06 -04:00
end
end
def pause
if Ci :: UpdateRunnerService . new ( @runner ) . update ( active : false )
2019-03-27 12:52:52 -04:00
redirect_to group_settings_ci_cd_path ( @group , anchor : 'runners-settings' ) , notice : _ ( 'Runner was successfully updated.' )
2018-04-10 00:29:06 -04:00
else
2019-03-27 12:52:52 -04:00
redirect_to group_settings_ci_cd_path ( @group , anchor : 'runners-settings' ) , alert : _ ( 'Runner was not updated.' )
2018-04-10 00:29:06 -04:00
end
end
private
2018-05-04 08:02:37 -04:00
def runner
2020-07-17 05:09:43 -04:00
@runner || = Ci :: RunnersFinder . new ( current_user : current_user , group : @group , params : { } ) . execute
. except ( :limit , :offset )
. find ( params [ :id ] )
2018-04-10 00:29:06 -04:00
end
def runner_params
params . require ( :runner ) . permit ( Ci :: Runner :: FORM_EDITABLE )
end
end