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
Add service_vars to pass variables between catalog items in a bundle #338
Conversation
Pull Request Test Coverage Report for Build 2784
💛 - Coveralls |
59e6c1c
to
bcc9298
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@lfu Looks good.
@bdunne @billfitzgerald0120 Please review. |
lib/miq_automation_engine/engine/miq_ae_method_service/miq_ae_service.rb
Outdated
Show resolved
Hide resolved
|
||
def set_service_vars_option(key, value) | ||
ar_method do | ||
@object.options[:service_vars] ||= HashWithIndifferentAccess.new |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to use HashWithIndifferentAccess
? I know we've had problems deserializing after upgrades before. cc @jrafanie
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see how a HWIA could be a problem. It does mask inconsistent "hash all the way down" interfaces but should be ok if we can't expect for client/consumers to use a consistent hash interface (string vs. symbols). 🤷♂
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIRC, the namespace of HWIA changed in a Rails version upgrade and we had to create an alias or something in order to deserialize them, but I can't find it right now so maybe I'm thinking of something else.
lib/miq_automation_engine/service_models/miq_ae_service_service.rb
Outdated
Show resolved
Hide resolved
bcc9298
to
fb78d74
Compare
@@ -48,6 +48,32 @@ def set_dialog_option(key, value) | |||
end | |||
end | |||
|
|||
def service_vars_options | |||
@object.options[:service_vars] || HashWithIndifferentAccess.new |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be ||=
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so.
|
||
def set_service_vars_option(key, value) | ||
ar_method do | ||
@object.options[:service_vars] ||= HashWithIndifferentAccess.new |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can the service_vars_options
method be reused here rather than duplicating it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the set
method. The other one is the get
method to retrieve data from DB.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think @bdunne is correct that this should reuse the service_vars_options
method and that the service_vars_options
method should use ||=
as mentioned above. That would reduce the places that have to know the options hash key and the HashWithIndifferentAccess
logic.
@@ -92,6 +92,37 @@ def ansible_stats_vars | |||
MiqAeEngine::MiqAeAnsibleMethodBase.ansible_stats_from_hash(@persist_state_hash) | |||
end | |||
|
|||
def service_object |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this only meant for internal use? If so it can be moved to the private
section of the file.
|
||
def set_service_vars_option(key, value) | ||
ar_method do | ||
@object.options[:service_vars] ||= HashWithIndifferentAccess.new |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think @bdunne is correct that this should reuse the service_vars_options
method and that the service_vars_options
method should use ||=
as mentioned above. That would reduce the places that have to know the options hash key and the HashWithIndifferentAccess
logic.
end | ||
|
||
def delete_service_vars_option(key) | ||
return unless @object.options[:service_vars]&.key?(key) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could use service_vars_options
as well.
74b05ba
to
b459521
Compare
b459521
to
a8eb5a3
Compare
Checked commit lfu@a8eb5a3 with ruby 2.4.6, rubocop 0.69.0, haml-lint 0.20.0, and yamllint 1.10.0 |
@miq-bot add_label changelog/yes |
https://bugzilla.redhat.com/show_bug.cgi?id=1678136
@miq-bot add_label enhancement, hammer/no