Skip to content

Commit

Permalink
Let stack_parameters support symbol hash keys, for now
Browse files Browse the repository at this point in the history
Service dialog options keys are supposed to be in String. But for some reason, API sends those keys in symbol when ordering a Service from global region.
Before we find out where those keys are duplicated in symbol via API, we have to work around it.

https://bugzilla.redhat.com/show_bug.cgi?id=1654999
  • Loading branch information
lfu committed Jan 18, 2019
1 parent d7a00ec commit 5cf587c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/models/service_orchestration/option_converter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def initialize(dialog_options)

def stack_parameters
params = {}
@dialog_options.each do |attr, val|
@dialog_options.with_indifferent_access.each do |attr, val|
if attr.start_with?('dialog_param_')
params[attr['dialog_param_'.size..-1]] = val
elsif attr.start_with?('password::dialog_param_')
Expand Down
14 changes: 12 additions & 2 deletions spec/models/service_orchestration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
'dialog_stack_onfailure' => 'ROLLBACK',
'dialog_stack_timeout' => '30',
'dialog_param_InstanceType' => 'cg1.4xlarge',
'password::dialog_param_DBRootPassword' => 'v2:{c2XR8/Yl1CS0phoOVMNU9w==}'
'password::dialog_param_DBRootPassword' => 'v2:{c2XR8/Yl1CS0phoOVMNU9w==}',
:dialog_param_key_in_symbol => 'not_expected'
}
end

Expand Down Expand Up @@ -106,6 +107,14 @@
expect(service_with_dialog_options.stack_options).to eq(dialog_options)
end

it "can access options key as string" do
expect(service_with_dialog_options.stack_options["dialog_stack_name"]).to eq('test123')
end

it "can access options key as symbol" do
expect(service_with_dialog_options.stack_options[:dialog_param_key_in_symbol]).to eq('not_expected')
end

context "cloud tenant option" do
it "parses a valid tenant option" do
dialog_options['dialog_tenant_name'] = 'abc'
Expand Down Expand Up @@ -206,7 +215,8 @@
allow_any_instance_of(OrchestrationStack).to receive(:raw_update_stack) do |_instance, new_template, opts|
expect(opts[:parameters]).to include(
'InstanceType' => 'cg1.4xlarge',
'DBRootPassword' => 'admin'
'DBRootPassword' => 'admin',
'key_in_symbol' => 'not_expected'
)
expect(new_template).to eq(template_by_setter)
end
Expand Down

0 comments on commit 5cf587c

Please sign in to comment.