From 86ab8b957e71f6ca1a2e05a06b64b27f0a12bd43 Mon Sep 17 00:00:00 2001 From: Matt Dziuban Date: Tue, 10 May 2016 13:35:59 -0400 Subject: [PATCH] Update all API methods to take options. --- lib/humidifier/aws_adapters/base.rb | 22 +++++++++++----------- lib/humidifier/stack.rb | 2 +- lib/humidifier/version.rb | 2 +- test/stack_test.rb | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/humidifier/aws_adapters/base.rb b/lib/humidifier/aws_adapters/base.rb index 0094e435..0542cfa9 100644 --- a/lib/humidifier/aws_adapters/base.rb +++ b/lib/humidifier/aws_adapters/base.rb @@ -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 diff --git a/lib/humidifier/stack.rb b/lib/humidifier/stack.rb index 9d28a228..bd3bfede 100644 --- a/lib/humidifier/stack.rb +++ b/lib/humidifier/stack.rb @@ -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 diff --git a/lib/humidifier/version.rb b/lib/humidifier/version.rb index d7126c78..ca6301e4 100644 --- a/lib/humidifier/version.rb +++ b/lib/humidifier/version.rb @@ -1,3 +1,3 @@ module Humidifier - VERSION = '0.0.29'.freeze + VERSION = '0.0.30'.freeze end diff --git a/test/stack_test.rb b/test/stack_test.rb index 003a41ed..ccb62176 100644 --- a/test/stack_test.rb +++ b/test/stack_test.rb @@ -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