Luke Kanies <[EMAIL PROTECTED]> writes:
> On Jul 16, 2008, at 9:49 AM, Daniel Pittman wrote:
>> Luke Kanies <[EMAIL PROTECTED]> writes:
>>>
>>> Not quite -- you'd need to recursively do this all the way up the
>>> scope chain.  For instance, 'operatingsystem' is set at the top-level
>>> scope, so it wouldn't even show up except in the top-level scope.
>>>
>>> This wouldn't make things fabulously more expensive, but it would
>>> have an impact, and it's why I didn't do things this way to start
>>> with.
>>
>> Mmmm.  So, do you have a strong preference for how this is fixed?
>>
>> I did a bit more poking around in Ruby and found, sadly, that there
>> doesn't seem to be any way to create a module, proc or object that is
>> free of the standard bindings.

[...]

> Why don't you try the recursive setting of instance variables and see
> how it performs?  It might be sufficient.

So, as expected this had the side-effect of making it impossible to
detect when an undefined variable was used in a template.  This was
quite a loss, in my opinion, and something I would rather not give up.

So, I spent some more time investigating this and came up with the patch
just sent to the list: it manually hides the Kernel methods, which are
the only ones (as far as I can determine) that cause us this grief.


This is a bit ugly, because it hard-codes the Kernel module, and because
it still risks shadows from other sources -- but it is, I think, the
best that can be done within the crippled meta-object protocol available
in Ruby.

I think it is preferable to the earlier version for two key reasons,
which justify the ugly nature of the code:

 * it retains the ability to signal a fatal error when an undefined
   puppet variable is used in a template

 * it retains the performance characteristics of O(n) searches where 
   n is the number of variables used, not the number visible.


The patch includes a test that verifies that a range of otherwise risky
kernel variables are safe to include and evaluate within the template
environment.

Any feedback would be welcome.

Regards,
        Daniel

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to