If I have attribute :sensitive, default: true on my resource
And the user does my_resource 'hi' do; puts sensitive; end
I expect it to print true (edited)
In the current Chef, it prints false
To resolve this you'll want to have the below in the resource:
def initialize(*args)
super
@sensitive = true
end
The reason that this returns an unexpected value is that the common property sensitive has a default value and because of how the initialization process works, if you're getting the default value for the common sensitive not the default you set. The line below is where the trouble originates from:
Given our discussion in IRC:
attribute :sensitive, default: true
on my resourcemy_resource 'hi' do; puts sensitive; end
true
(edited)In the current Chef, it prints
false
To resolve this you'll want to have the below in the resource:
The reason that this returns an unexpected value is that the common property
sensitive
has a default value and because of how the initialization process works, if you're getting the default value for the commonsensitive
not the default you set. The line below is where the trouble originates from:https://github.com/chef/chef/blob/master/lib/chef/resource.rb#L161
For the interim:
sensitive
you could use the above fix to basically override that defaultCheers!
(feel free to close the issue, just wanted to follow up since we nailed this down)