Class: StaticSiteEditor::ConfigService

Inherits:
BaseContainerService show all
Defined in:
app/services/static_site_editor/config_service.rb

Constant Summary collapse

ValidationError =
Class.new(StandardError)

Instance Attribute Summary

Attributes inherited from BaseContainerService

#container, #current_user, #params

Instance Method Summary collapse

Methods inherited from BaseContainerService

#group_container?, #namespace_container?, #project_container?

Methods included from BaseServiceUtility

#deny_visibility_level, #event_service, #log_error, #log_info, #notification_service, #system_hook_service, #todo_service, #visibility_level

Methods included from Gitlab::Allowable

#can?

Constructor Details

#initialize(container:, current_user: nil, params: {}) ⇒ ConfigService

Returns a new instance of ConfigService.


7
8
9
10
11
12
13
# File 'app/services/static_site_editor/config_service.rb', line 7

def initialize(container:, current_user: nil, params: {})
  super

  @project = container
  @repository = project.repository
  @ref = params.fetch(:ref)
end

Instance Method Details

#executeObject


15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/services/static_site_editor/config_service.rb', line 15

def execute
  check_access!

  file_config = load_file_config!
  file_data = file_config.to_hash_with_defaults
  generated_data = load_generated_config.data

  check_for_duplicate_keys!(generated_data, file_data)
  data = merged_data(generated_data, file_data)

  ServiceResponse.success(payload: data)
rescue ValidationError => e
  ServiceResponse.error(message: e.message)
rescue StandardError => e
  Gitlab::ErrorTracking.track_and_raise_exception(e)
end