-
Notifications
You must be signed in to change notification settings - Fork 28
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
MergedConfig: Use Chef::Mash as storage #115
Conversation
@@ -24,7 +24,7 @@ def [](name) | |||
else | |||
result_configs = [] | |||
configs.each do |config| | |||
value = config[name] | |||
value = config[name.to_s] || config[name.to_sym] |
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 your intention to set value
to a string regardless of the original object type of name
?
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 also am concerned as I think this will cause the value to never be equal to nil
, since it would convert the value of nil
to a empty string.
Eg:
[1] pry(main)> (nil).nil?
=> true
[2] pry(main)> (nil.to_s).nil?
=> false
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.
@rhass I'm not sure I understand your comment. I'm only casting the key to a string or symbol. The value will still be nil
if the hash has neither the key 'key'
nor :key
kind of 👎 on this one since i'm failure sure this just needs to be a Chef::Mash or needs to use mixlib-config or Chef::Config or something like that... this is already a solved problem, and we should definitely re-use the solution instead of inventing a new problem. |
@lamont-granquist: Yeah, I'd rather switch the underlying implementation of MergedConfig to a Mash if it's ok with you |
e3f78a7
to
f825b39
Compare
To address @lamont-granquist and @rhass comments, I've switched the underlying storage to Chef::Mash, which address the initial issue, and reuse existing code with a known semantic. |
f825b39
to
dcbe0b4
Compare
I've also added a few specs for the MergedConfig |
68ac499
to
70ff703
Compare
Signed-off-by: Julien 'Lta' BALLET <[email protected]>
70ff703
to
a953bd0
Compare
ah i was hoping we could nuke the whole class, now i sort of see what else its trying to do. but 👍 for fixing the issue at hand this way. i'll have to dig into it to see why it seems to be trying to reimplement attribute precedence levels and if we can avoid that... @thommay i'm 👍 on it the way it is. we need to deprecate and kill off them method_missing here as well... |
Merging this looks to have broken Chef Provisioning in the latest ChefDK. The issue arises when calling In cheffish < 4.1 the |
It seems to me like this is breaking behavior. Calling |
This is the correct behavior. We can do the dance of bumping cheffish to 5.0 but there's no going back. |
I'm okay with that. But can we revert this, release |
@lamont-granquist 🤗 Thank you! |
When you have a MergedConfig with two config defining the 'same' key, but one as a string and one as a symbol, you end up having this very confusing behavior:
This PR address this behavior. I hope but doubt this is an appropriate fix, so let me know what you think about it
Signed-off-by: Julien 'Lta' BALLET [email protected]