Class: Ci::ListConfigVariablesService

Inherits:
BaseService show all
Includes:
ReactiveCaching
Defined in:
app/services/ci/list_config_variables_service.rb

Constant Summary

Constants included from ReactiveCaching

ReactiveCaching::ExceededReactiveCacheLimit, ReactiveCaching::InvalidateReactiveCache, ReactiveCaching::WORK_TYPE

Instance Attribute Summary

Attributes inherited from BaseService

#current_user, #params, #project

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseService

#initialize

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?, #can_all?, #can_any?

Constructor Details

This class inherits a constructor from BaseService

Class Method Details

.from_cache(id) ⇒ Object



11
12
13
14
15
16
17
18
# File 'app/services/ci/list_config_variables_service.rb', line 11

def self.from_cache(id)
  project_id, user_id = id.split('-')

  project = Project.find(project_id)
  user = User.find(user_id)

  new(project, user)
end

Instance Method Details

#calculate_reactive_cache(sha, ref) ⇒ Object



27
28
29
30
31
32
33
34
35
# File 'app/services/ci/list_config_variables_service.rb', line 27

def calculate_reactive_cache(sha, ref)
  config = ::Gitlab::Ci::ProjectConfig.new(project: project, sha: sha)

  return {} unless config.exists?

  result = execute_yaml_processor(sha, ref, config)

  result.valid? ? result.root_variables_with_prefill_data : {}
end

#execute(ref) ⇒ Object



20
21
22
23
24
25
# File 'app/services/ci/list_config_variables_service.rb', line 20

def execute(ref)
  # "ref" is not a enough for a cache key because the name is static but that branch can be changed any time
  sha = project.commit(ref).try(:sha)

  with_reactive_cache(sha, ref) { |result| result }
end

#idObject

Required for ReactiveCaching, it is also used in ‘reactive_cache_worker_finder`



38
39
40
# File 'app/services/ci/list_config_variables_service.rb', line 38

def id
  "#{project.id}-#{current_user.id}"
end