From 6f09f76da18e059353fff1380ef57db831ff0399 Mon Sep 17 00:00:00 2001 From: Dave Steinberg Date: Wed, 31 Jul 2024 15:57:35 +0000 Subject: [PATCH] Support non-camel-case stack outputs --- lib/stack_master/parameter_resolvers/stack_output.rb | 2 +- .../parameter_resolvers/stack_output_spec.rb | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/stack_master/parameter_resolvers/stack_output.rb b/lib/stack_master/parameter_resolvers/stack_output.rb index 80658cef..4f4c6874 100644 --- a/lib/stack_master/parameter_resolvers/stack_output.rb +++ b/lib/stack_master/parameter_resolvers/stack_output.rb @@ -18,7 +18,7 @@ def resolve(value) region, stack_name, output_name = parse!(value) stack = find_stack(stack_name, region) if stack - output = stack.outputs.find { |stack_output| stack_output.output_key == output_name.camelize } + output = stack.outputs.find { |stack_output| stack_output.output_key == output_name.camelize || stack_output.output_key == output_name } if output output.output_value else diff --git a/spec/stack_master/parameter_resolvers/stack_output_spec.rb b/spec/stack_master/parameter_resolvers/stack_output_spec.rb index d729d299..dbbee720 100644 --- a/spec/stack_master/parameter_resolvers/stack_output_spec.rb +++ b/spec/stack_master/parameter_resolvers/stack_output_spec.rb @@ -67,6 +67,15 @@ def resolve(value) resolver.resolve("ap-southeast-2:#{value}") end + context 'when the output key has a non-camel name' do + let(:value) { 'my-stack/my_Output' } + let(:outputs) { [{output_key: 'my_Output', output_value: 'myresolvedvalue'}] } + + it 'resolves the value' do + expect(resolved_value).to eq 'myresolvedvalue' + end + end + context "when different credentials are used" do let(:outputs_in_account_2) { [ {output_key: 'MyOutput', output_value: 'resolvedvalueinaccount2'} ] } let(:stacks_in_account_2) { [{ stack_name: 'other-stack', creation_time: Time.now, stack_status: 'CREATE_COMPLETE', outputs: outputs_in_account_2}] }