Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save newly created dialog_id in options #14254

Merged
merged 1 commit into from
Mar 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions app/models/service_template_ansible_playbook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ def self.create_catalog_item(options, auth_user)
next unless dialog_name

job_template = enhanced_config.fetch_path(action, :configuration_template)
enhanced_config[action][:dialog] =
Dialog::AnsiblePlaybookServiceDialog.create_dialog(dialog_name, job_template)
new_dialog = Dialog::AnsiblePlaybookServiceDialog.create_dialog(dialog_name, job_template)
enhanced_config[action][:dialog] = new_dialog
service_template.options[:config_info][action][:dialog_id] = new_dialog.id
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense to extract the logic from Line 47 - 49 into a separate method? I think it may make what is happening in the transaction easier to read.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@syncrou I have given it a lot of thoughts but still prefer the way as is. Line 48 and 49 use the result from Line 47. They are two very different hashes. If we pass them into a method as arguments and modify the hash content, it will be even harder to read or realize the hash content has been modified after the method call.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bzwei - Makes sense. I was picturing a single method name detailing actions required for creating the dialog - I can get behind the code where it is at after reading your response.

👍 Looks good to me.

service_template.create_resource_actions(enhanced_config)
end
Expand Down
3 changes: 3 additions & 0 deletions spec/models/service_template_ansible_playbook_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@
:fqname => described_class.default_provisioning_entry_point('atomic'),
:configuration_template => job_template
)

saved_options = catalog_item_options_two[:config_info].deep_merge(:provision => {:dialog_id => service_template.dialogs.first.id})
expect(service_template.options[:config_info]).to include(saved_options)
end
end
end