Method: Cfer::Core::Stack#initialize
- Defined in:
- lib/cfer/core/stack.rb
#initialize(options = {}) ⇒ Stack
Returns a new instance of Stack.
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/cfer/core/stack.rb', line 30 def initialize( = {}) self[:AWSTemplateFormatVersion] = '2010-09-09' self[:Description] = '' = self[:Metadata] = { :Cfer => { :Version => Cfer::SEMANTIC_VERSION.to_h.delete_if { |k, v| v === nil } } } self[:Parameters] = {} self[:Mappings] = {} self[:Conditions] = {} self[:Resources] = {} self[:Outputs] = {} if [:client] && git = [:client].git begin @git_state = git.object('HEAD^') self[:Metadata][:Cfer][:Git] = { Rev: git_state.sha, Clean: git.status.changed.empty? } rescue => e Cfer::LOGGER.warn("Unable to add Git information to CloudFormation Metadata. #{e}") end end @parameters = HashWithIndifferentAccess.new @input_parameters = HashWithIndifferentAccess.new if [:client] begin @parameters.merge! [:client].fetch_parameters rescue Cfer::Util::StackDoesNotExistError Cfer::LOGGER.debug "Can't include current stack parameters because the stack doesn't exist yet." end end if [:parameters] [:parameters].each do |key, val| @input_parameters[key] = @parameters[key] = val end end end |