Class: Covalence::Stack

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Validations
Defined in:
lib/covalence/core/entities/stack.rb

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}, *arguments) ⇒ Stack

Returns a new instance of Stack.



35
36
37
38
# File 'lib/covalence/core/entities/stack.rb', line 35

def initialize(attributes = {}, *arguments)
  super
  self.valid?
end

Instance Method Details

#full_nameObject



40
41
42
# File 'lib/covalence/core/entities/stack.rb', line 40

def full_name
  "#{environment_name}-#{name}"
end

#loggerObject



69
70
71
# File 'lib/covalence/core/entities/stack.rb', line 69

def logger
  Covalence::LOGGER
end

#materialize_cmd_inputs(path) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/covalence/core/entities/stack.rb', line 44

def materialize_cmd_inputs(path)
  if type == "terraform"
    config = ""
    inputs.values.map(&:to_command_option).each do |input|
      config += input + "\n"
    end
    logger.info "#{module_path} \nStack inputs:\n\n#{config}"
    File.open("#{path}/covalence-inputs.tfvars",'w') {|f| f.write(config)}
  elsif type == "packer"
    config = Hash.new
    inputs.each do |name, input|
      config[name] = input.value
    end
    config_json = JSON.generate(config)
    logger.info "\nStack inputs:\n\n#{config_json}"
    File.open('covalence-inputs.json','w') {|f| f.write(config_json)}
  end
end

#materialize_state_inputs(store: state_stores.first) ⇒ Object



63
64
65
66
67
# File 'lib/covalence/core/entities/stack.rb', line 63

def materialize_state_inputs(store: state_stores.first)
  config = store.get_config
  logger.info "\nState store configuration:\n\n#{config}"
  File.open('covalence-state.tf','w') {|f| f.write(config)}
end