2018-12-05 23:21:45 +05:30
# frozen_string_literal: true
2017-09-10 17:25:29 +05:30
module Groups
module Settings
class CiCdController < Groups :: ApplicationController
2021-04-29 21:17:54 +05:30
layout 'group_settings'
2018-03-27 19:54:05 +05:30
skip_cross_project_access_check :show
2019-01-03 12:48:30 +05:30
before_action :authorize_admin_group!
2019-12-21 20:55:43 +05:30
before_action :authorize_update_max_artifacts_size! , only : [ :update ]
2020-04-25 10:58:03 +05:30
before_action :define_variables , only : [ :show ]
2021-04-29 21:17:54 +05:30
before_action :push_licensed_features , only : [ :show ]
2022-07-23 23:45:48 +05:30
before_action :assign_variables_to_gon , only : [ :show ]
2017-09-10 17:25:29 +05:30
2021-01-03 14:25:43 +05:30
feature_category :continuous_integration
2022-07-16 23:28:13 +05:30
urgency :low
2020-07-28 23:09:34 +05:30
2017-09-10 17:25:29 +05:30
def show
2023-03-04 22:38:38 +05:30
@entity = :group
@variable_limit = :: Plan . default . actual_limits . group_ci_variables
2017-09-10 17:25:29 +05:30
end
2019-12-21 20:55:43 +05:30
def update
if update_group_service . execute
flash [ :notice ] = s_ ( 'GroupSettings|Pipeline settings was updated for the group' )
else
2023-03-17 16:20:25 +05:30
flash [ :alert ] = format ( s_ ( " GroupSettings|There was a problem updating the pipeline settings: %{error_messages}. " ) , error_messages : group . errors . full_messages )
2019-12-21 20:55:43 +05:30
end
redirect_to group_settings_ci_cd_path
end
2019-07-07 11:18:12 +05:30
def update_auto_devops
if auto_devops_service . execute
flash [ :notice ] = s_ ( 'GroupSettings|Auto DevOps pipeline was updated for the group' )
else
2023-03-17 16:20:25 +05:30
flash [ :alert ] = format ( s_ ( " GroupSettings|There was a problem updating Auto DevOps pipeline: %{error_messages}. " ) , error_messages : group . errors . full_messages )
2019-07-07 11:18:12 +05:30
end
2018-12-05 23:21:45 +05:30
redirect_to group_settings_ci_cd_path
end
2017-09-10 17:25:29 +05:30
private
2020-04-08 14:13:33 +05:30
def define_variables
define_ci_variables
2021-10-27 15:23:28 +05:30
define_view_variables
2020-04-08 14:13:33 +05:30
end
2018-12-13 13:39:08 +05:30
def define_ci_variables
2017-09-10 17:25:29 +05:30
@variable = Ci :: GroupVariable . new ( group : group )
. present ( current_user : current_user )
@variables = group . variables . order_key_asc
. map { | variable | variable . present ( current_user : current_user ) }
end
2021-10-27 15:23:28 +05:30
def define_view_variables
@content_class = 'limit-container-width' unless fluid_layout
end
2019-01-03 12:48:30 +05:30
def authorize_admin_group!
return render_404 unless can? ( current_user , :admin_group , group )
2017-09-10 17:25:29 +05:30
end
2019-07-07 11:18:12 +05:30
2019-12-21 20:55:43 +05:30
def authorize_update_max_artifacts_size!
return render_404 unless can? ( current_user , :update_max_artifacts_size , group )
end
2019-07-07 11:18:12 +05:30
def auto_devops_params
params . require ( :group ) . permit ( :auto_devops_enabled )
end
def auto_devops_service
Groups :: AutoDevopsService . new ( group , current_user , auto_devops_params )
end
2019-12-21 20:55:43 +05:30
def update_group_service
Groups :: UpdateService . new ( group , current_user , update_group_params )
end
def update_group_params
params . require ( :group ) . permit ( :max_artifacts_size )
end
2021-04-29 21:17:54 +05:30
# Overridden in EE
def push_licensed_features
end
2022-07-23 23:45:48 +05:30
# Overridden in EE
def assign_variables_to_gon
end
2017-09-10 17:25:29 +05:30
end
end
end
2021-04-29 21:17:54 +05:30
2021-06-08 01:23:25 +05:30
Groups :: Settings :: CiCdController . prepend_mod_with ( 'Groups::Settings::CiCdController' )