lib/cfer/core/stack.rb in cfer-0.6.2 vs lib/cfer/core/stack.rb in cfer-0.7.0

- old
+ new

@@ -11,11 +11,11 @@ # The fully resolved parameters, including defaults and parameters fetched from an existing stack during an update attr_reader :parameters attr_reader :options - attr_reader :git_version + attr_reader :git_state def client @options[:client] || raise('No client set on this stack') end @@ -43,15 +43,20 @@ self[:Mappings] = {} self[:Conditions] = {} self[:Resources] = {} self[:Outputs] = {} - if options[:client] && git = options[:client].git && @git_version = (git.object('HEAD^').sha rescue nil) - self[:Metadata][:Cfer][:Git] = { - Rev: @git_version, - Clean: git.status.changed.empty? - } + if options[:client] && git = options[: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 @@ -138,10 +143,10 @@ clazz = Cfer::Core::Resource.resource_class(type) rc = clazz.new(name, type, self, options, &block) self[:Resources][name] = rc - rc + rc.handle end # Adds an output to the CloudFormation stack. # @param name [String] The Logical ID of the output parameter # @param value [String] Value to return