Class: Covalence::StackRepository

Inherits:
Object
  • Object
show all
Defined in:
lib/covalence/core/repositories/stack_repository.rb

Class Method Summary collapse

Class Method Details

.find(data_store, environment_name, stack_name) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/covalence/core/repositories/stack_repository.rb', line 11

def self.find(data_store, environment_name, stack_name)
  stack_scope = {
    'environment' => environment_name,
    'stack' => stack_name,
  }
  tool = lookup_tool(data_store, stack_scope)
  return if tool.nil?

  stack_data_store = data_store.initialize_scope(stack_scope)
  stack_module = lookup_shared_namespace(stack_data_store, stack_name)
  shared_namespace = stack_module.gsub('/', '::') unless stack_module.nil?

  Stack.new(
    type: tool,
    name: stack_name,
    environment_name: environment_name,
    module_path: stack_module,
  )
end

.populate(data_store, stack) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/covalence/core/repositories/stack_repository.rb', line 31

def self.populate(data_store, stack)
  stack_scope = {
    'environment' => stack.environment_name,
    'stack' => stack.name,
  }
  stack_data_store = data_store.initialize_scope(stack_scope)
  shared_namespace = stack.module_path.gsub('/', '::')

  stack.dependencies = lookup_dependencies(stack_data_store, stack.name)
  stack.packer_template = lookup_packer_template(stack_data_store, stack.name)
  stack.workspace = lookup_workspace(stack_data_store, stack.name)
  stack.state_stores = StateStoreRepository.query_by_stack_name(stack_data_store, stack.name, stack.workspace, stack.type)
  stack.contexts = ContextRepository.query_by_namespace(stack_data_store, shared_namespace, stack.type)
  stack.inputs = InputRepository.query_by_namespace(stack_data_store, shared_namespace, stack.type)
  stack.args = find_args_by_namespace(stack_data_store, shared_namespace)
end