Open alicebob opened 7 years ago
Yeah, the optioncollector helper is from before the lazy{}
helper worked on instances. There doesn't look to be a great solution here other than fixing it in Poise itself.
Thanks @coderanger!
Would it be a matter of adding
arg = instance_eval(&arg) if arg.is_a?(Chef::DelayedEvaluator)
right after this if
: https://github.com/poise/poise/blob/master/lib/poise/helpers/option_collector.rb#L110 ?
I can try that, but I have no idea where the tests for this have to go.
Unfortunately no, that would fix the error but you wouldn't actually get the delayed evaluation behavior (i.e. the eval would happen at set time). It needs a bigger rewrite :-/ The way the lazy{}
helper in that use case works is by delaying the eval until acess, rather than running it on set. Basically the whole helper as written needs to be scrapped and rewritten using the newer Property API which was built explicitly to make this easier for me in the future but that requires time on my part as well as either backporting the Property system or dropping support for early 12.x releases.
Ugh. Makes sense that doesn't work. I'll see if I can solve this some other way; I'm sure I can somehow reorder things as a workaround.
Thanks for the quick help!
(I'll leave the issue open in case someone else runs into the same problem. Feel free to close as you see fit)
btw, there seems to be something wrong with the exception above, that might be fixable :)
Check if poise-derived
might help fix the root issues you are having. Worth a shot at least.
Hi,
I'm having some trouble with a lazy option_collector attribute value, and looking at the Poise code it seems there is no support for that. Am I right?
I want to use the :parameters option from the consul cookbook. Source of the resource: https://github.com/johnbellone/consul-cookbook/blob/dec40396bea00b3f24b966291bde399e1162d981/libraries/consul_definition.rb#L36
This is what I'm trying to do:
This is the error I get:
The documentation for
lazy
suggests that what I'm trying to do should work for non-poise use: https://docs.chef.io/resource_common.html#lazy-evaluationAny ideas? Thanks!