Skip to content

Commit

Permalink
Merge pull request #13 from localytics/allow-passing-options
Browse files Browse the repository at this point in the history
Allow passing options to AWS API calls
  • Loading branch information
mrdziuban committed May 10, 2016
2 parents 4b7e2ce + 86ab8b9 commit 9809f98
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
22 changes: 11 additions & 11 deletions lib/humidifier/aws_adapters/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,29 @@ module Humidifier
module AwsAdapters
class Base

def create_stack(stack)
try_valid { client.create_stack(stack_name: stack.name, template_body: stack.to_cf) }
def create_stack(stack, options = {})
try_valid { client.create_stack({ stack_name: stack.name, template_body: stack.to_cf }.merge(options)) }
end

def delete_stack(stack)
client.delete_stack(stack_name: stack.name)
def delete_stack(stack, options = {})
client.delete_stack({ stack_name: stack.name }.merge(options))
true
end

def deploy_stack(stack)
stack_exists?(stack) ? update_stack(stack) : create_stack(stack)
def deploy_stack(stack, options = {})
stack_exists?(stack) ? update_stack(stack, options) : create_stack(stack, options)
end

def stack_exists?(stack)
def stack_exists?(stack, _ = {})
base_module::CloudFormation::Stack.new(name: stack.name).exists?
end

def update_stack(stack)
try_valid { client.update_stack(stack_name: stack.name, template_body: stack.to_cf) }
def update_stack(stack, options = {})
try_valid { client.update_stack({ stack_name: stack.name, template_body: stack.to_cf }.merge(options)) }
end

def validate_stack(stack)
try_valid { client.validate_template(template_body: stack.to_cf) }
def validate_stack(stack, options = {})
try_valid { client.validate_template({ template_body: stack.to_cf }.merge(options)) }
end

private
Expand Down
2 changes: 1 addition & 1 deletion lib/humidifier/stack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def to_cf
end

AwsShim::STACK_METHODS.each do |stack_method, shim_method|
define_method(stack_method) { AwsShim.send(shim_method, self) }
define_method(stack_method) { |opts = {}| AwsShim.send(shim_method, self, opts) }
end

private
Expand Down
2 changes: 1 addition & 1 deletion lib/humidifier/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Humidifier
VERSION = '0.0.29'.freeze
VERSION = '0.0.30'.freeze
end
2 changes: 1 addition & 1 deletion test/stack_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def enumerable_resources
def with_mocked_aws_shim(method)
stack = Humidifier::Stack.new(name: 'test-stack')
mock = Minitest::Mock.new
mock.expect(:call, nil, [stack])
mock.expect(:call, nil, [stack, {}])

Humidifier::AwsShim.stub(method, mock) do
yield stack
Expand Down

0 comments on commit 9809f98

Please sign in to comment.