-
Notifications
You must be signed in to change notification settings - Fork 683
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
Bug fix for loading hashmap inputs consistently #5446
Conversation
…adata file Signed-off-by: Nikita Mathur <nikita.mathur@chef.io>
Deploy preview for chef-inspec canceled. Built with commit 82e1267 https://app.netlify.com/sites/chef-inspec/deploys/606d8bf9b313d6000850652f |
c1664e9
to
d0c17b3
Compare
…sh type Signed-off-by: Nikita Mathur <nikita.mathur@chef.io>
d0c17b3
to
a55b083
Compare
@aaronlippold Does this approach - using HashWithIndifferentAccess - work for your use case? |
lib/inspec/input_registry.rb
Outdated
@@ -256,7 +256,7 @@ def bind_inputs_from_input_files(profile_name, file_list) | |||
|
|||
data.inputs.each do |input_name, input_value| | |||
evt = Inspec::Input::Event.new( | |||
value: input_value, | |||
value: input_value.is_a?(Hash) ? Thor::CoreExt::HashWithIndifferentAccess.new(input_value) : input_value, |
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.
For consistency, I wonder if we should make a similar change in bind_inputs_from_runner_api
? Testing that would be difficult, however.
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.
Yes for consistency that seems right. Let me look into the testing front for this.
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 we add a method to handle this conversion input_value.is_a?(Hash) ? Thor::CoreExt::HashWithIndifferentAccess.new(input_value) : input_value
so that we can just call that method wherever required and code will be maintainable ?
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.
Yes these checks could be re-used by having just a method :)
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.
@clintoncwolfe I observed this issue not only additionally happens for runner api input but also for other ways of input. Will try an alternate solution which could work for all the input types, rather than handling it in each method definition for different input types. Hope that would be a better solution.
I'm not sure given that there isn't really a description of the change. Can you elaborate on what is being updated and remind me which use case we're talking about :-) |
Signed-off-by: Nikita Mathur <nikita.mathur@chef.io>
Signed-off-by: Nikita Mathur <nikita.mathur@chef.io>
41c696c
to
6cc4fc9
Compare
Signed-off-by: Nikita Mathur <nikita.mathur@chef.io>
6cc4fc9
to
82e1267
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.
Great testing - very good work!
Signed-off-by: Nikita Mathur nikita.mathur@chef.io
Description
Issues:
symbol
keys and another hash withstring
as keysImpact of solution:
This approach will solve reading inputs irrespective of their formats, which enables using hashes inside InSpec controls in any way preferred.
Related Issue
Fixes #4057
Types of changes
Checklist: