Skip to content

Commit

Permalink
Force template body to a JSON string if enumerable is detected
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisroberts committed Aug 20, 2014
1 parent 934b420 commit 3842c32
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions lib/fog/aws/models/orchestration/stack.rb
Expand Up @@ -29,7 +29,7 @@ class Stack < Fog::Orchestration::Stack
# valid options for stack create and update actions
ALLOWED_OPTIONS = {
:create => [
:template, :template_url, :disable_rollback, :parameters, :timeout_in_minutes, :capabilities
:template, :template_url, :disable_rollback, :parameters, :timeout_in_minutes, :capabilities, :notification_topics
],
:update => [
:template, :template_url, :parameters
Expand All @@ -43,7 +43,7 @@ class Stack < Fog::Orchestration::Stack
:capabilities => 'Capabilities',
:disable_rollback => 'DisableRollback',
:timeout_in_minutes => 'TimeoutInMinutes',
:notification_arns => 'NotificationARNs'
:notification_topics => 'NotificationARNs'
}

# Generate API options hash for action
Expand Down Expand Up @@ -103,6 +103,19 @@ def template
attributes[:template]
end

# Set stack template
#
# @param template_body [String, Hash] stack template
# @return [String]
# @note if data structure provided, it will be dumped to JSON
# content and stored
def template=(template_body)
unless(template_body.is_a?(String))
template_body = Fog::JSON.encode(template_body)
end
attributes[:template] = template_body
end

# Validate the template of the stack
#
# @return [TrueClass]
Expand Down

0 comments on commit 3842c32

Please sign in to comment.