[chef] Re: Re: Does remote_file not support lazy attributes?


Chronological Thread 
  • From: Jeppe Nejsum Madsen < >
  • To: " " < >
  • Subject: [chef] Re: Re: Does remote_file not support lazy attributes?
  • Date: Sun, 30 Mar 2014 17:00:17 +0200

Thanks!


/Jeppe


On Fri, Mar 28, 2014 at 7:26 AM, Steven Danna < " target="_blank"> > wrote:
Hi,

I've filed a bug on this here: https://tickets.opscode.com/browse/CHEF-5162

Cheers,

Steven

On Thu, Mar 27, 2014 at 9:48 PM, Steven Danna < "> > wrote:
> Hi,
>
> Unfortunately, this looks like a bug.  When the lazy method is called,
> it creates a Chef::DelayedEvaluator object.  This
> Chef::DelayedEvaluator is what gets passed to the source attribute's
> setter method in the resource.  Most resource attribute setter methods
> use the helper function set_or_return().  When Chef::DelayedEvaluator
> was introduced, set_or_return was patched to ignore validatons if it
> got a DelayedEvaluator.  The tradeoff for the power of lazy evaluation
> is no "compile phase" type checking of arguments.
>
> remote_file's source resource, however, uses a custom method for validation:
>
>       def validate_source(source)
>         raise ArgumentError, "#{resource_name} has an empty source" if
> source.empty?
>         source.each do |src|
>           unless absolute_uri?(src)
>             raise Exceptions::InvalidRemoteFileURI,
>               "#{src.inspect} is not a valid `source` parameter for
> #{resource_name}. `source` must be an absolute URI or an array of
> URIs."
>           end
>         end
>       end
>
> This function and others like it need to be patched to accept
> DelayedEvaluators. I shall make with the typing into JIRA.
>
> Sincerely,
>
> Steven
>
> On Tue, Mar 25, 2014 at 4:58 AM, Jeppe Nejsum Madsen < "> > wrote:
>> I get the following when trying to use a lazy attribute:
>>
>>
>> This is the chef-shell.
>>  Chef Version: 11.10.4
>>
>> chef:recipe > remote_file "/tmp/g2" do
>> chef:recipe > source lazy {"http://www.google.com"}
>> chef:recipe ?> end
>> Chef::Exceptions::InvalidRemoteFileURI:
>> #<Chef::DelayedEvaluator:0x007fd464c092a8@(irb#1):7> is not a valid `source`
>> parameter for remote_file. `source` must be an absolute URI or an array of
>> URIs.
>>
>> Any hints?
>>
>> /Jeppe
>>




Archive powered by MHonArc 2.6.16.

§