On Wed, Mar 26, 2014 at 8:15 AM, David Schmitt <[email protected]> wrote:

> On 2014-03-26 11:09, Craig Dunn wrote:
>
>> ### Global `$facts` Hash
>>>
>>> You have to manually enable this (along with the `$trusted` hash) by
>>>  on your puppet master(s). Itll be on by default in Puppet 4.
>>>
>>>
>>> In addition to using `$fact_name`, you can now use
>>> `$facts[fact_name]` to get a fact value. The `$facts` hash is
>>> protected and cant be overridden locally, so you wont need the `$::`
>>>
>>> idiom when using this.
>>>
>>> Our hope is that this will visibly distinguish facts from normal
>>> variables, make Puppet code more readable, and eventually clean up
>>> the global variable namespace. (Thatll take a while, though --- we
>>> probably wont be able to disable `$fact_name` until, like, Puppet
>>> 5.)
>>>
>>
>>
>>  Out of curiosity what is the reasoning behind making facts different
>> from normal variables?  What is special about them compared to
>> top-level variables, hiera data or ENC variables? Whilst I think
>> having facts in their own protected namespace/hash is a long overdue
>> and very good idea, in my opinion having it scoped as a top-scope hash
>> and referenced as $::facts[value] is not only more familiar to people
>> already using Puppet but is also a lot easier to understand than
>> making them "special" and referencing them as if they were locally
>> scoped - to me that makes the code less readable, rather than more.
>>
>
>
> Without being involved in the design of that, I'd venture that this is
> backed by the same reason that PHP has recently removed register_globals:
> avoid allowing lesser trusted parts of the system to provide values in
> unexpected regions of the code.
>
>
Yes, that was the reasoning.

On the question about it being a top-scope variable: it still is. You can
reference it like that as well ($::facts), but with the extra checks to
prevent shadowing you don't have to.


>
> Regards, David
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Puppet Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/puppet-dev/21cc8fb5a7a4daf97c6369c1bb28827e%40hosting.edv-bus.at.
>
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Andrew Parker
[email protected]
Freenode: zaphod42
Twitter: @aparker42
Software Developer

*Join us at PuppetConf 2014, September 23-24 in San Francisco - *
http://bit.ly/pupconf14

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-dev/CANhgQXs%2BL6hHvsZz46RJJeQD-Lcc4sDExhe15NMwhg8rqmx1%2BA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to