We previously had the schedule checking code in Puppet::Type,
but it's more of a transactional function, and in order to
do proper auditing in the transactional area, we need the
cache checking done there. Scheduling is one
of the few functions that actually uses cached data currently.
Signed-off-by: Luke Kanies <luke@puppetlabs.com>
The previous code maintained thread safety up to work-duplication (so that a
collision would, at worse, result in effective cache flushing and cause some
additional work to be done). The preceding patch addressed the single thread
issue of environment specific functions; this patch brings the thread safety
up to the previous standard.
Jesse and I are shooting for the minimal viable fix here, with the idea that
a great deal of refactoring is needed but isn't appropriate at this time. The
changes in this commit are:
* Index the function-holding modules by environment
* We need to know the "current environment" when we're defining a function so
we can attach it to the proper module, and this information isn't dynamically
available when user-defined functions are being created (we're being called by
user written code that doesn't "know" about environments) so we cheat and
stash the value in Puppet::Node::Environment
* since we must do this anyway, it turns out to be cleaner & safer to do the
same when we are evaluating a functon. This is the main change from the prior
version of this patch.
* Add a special *root* environment for the built in functions, and extend all
scopes with it.
* Index the function characteristics (name, type, docstring, etc.) by environment
* Make the autoloader environment aware, so that it uses the modulepath for the
specified environment rather than the default
* Turn off caching of the modulepath since it potentially changes for each node
* Tweak tests that weren't environment aware
This patch implements the fundamental pieces of the move to composite
keys:
* Instead of having a single namevar, we have a non-empty collection
of them, and two resources are the same if and only if all of them
match. Note that the present situation is a special case of this,
where the collection always has exactly one member.
* As currently, namevar is determined by the type.
* Instead just of inferring the single namevar from the title we let
types decompose the title into values for several (perhaps all) of
the namevar components; note that the present situation is again a
special case of this.
Signed-off-by: Jesse Wolfe <jes5199@gmail.com>
Jesse moved the code David was patching; the conflict resolution omits David's
change (since the code isn't there to be changed) and this moves the change to
the new location.
Win32 paths start with a drive letter, a colon and a slash;
UNC paths start with two slashes, the name of the server and another slash.
Signed-off-by: David Schmitt <david@dasz.at>
We were previously adding them directly to Scope, but
now they're in a module that Scope includes.
This is the first half of #1175 - we can now maintain
environment-specific collections of functions. We need
some way of tracking which environment a given function
is loaded from.
Well, maybe it's the first third - the core functions
probably need to be added to all of these modules,
or there needs to be a 'common' module that is included by
all of them.
Signed-off-by: Luke Kanies <luke@reductivelabs.com>
Syck/Yaml quietly passes on undefined classes as strings, so that if objects
of those classes are loaded and re-serialized they passthrough unmodified.
While not technically correct, it's still the POLS behavior, and we now support
it.
The metaid.rb file came straight from why the lucky stiff's "seeing
metaclasses clearly" article. Rails used this too, but they recently
deprecated the name metaclass in favor of singleton_class to match what
ruby-core decided to do. meta, eigen and singlton class were all
suggested and in the end singleton was agreed upon.
http://redmine.ruby-lang.org/issues/show/1082
If you have the following code or equivalent:
file { "/foo": content => "{md5}foobar" }
Puppet will attempt to pull the content associated with
that file from whatever the default filebucket is for the
resource in question.
Signed-off-by: Luke Kanies <luke@puppetlabs.com>
The FileBucket code had a bunch of checksum code
that was already available in a library, and it used a
checksum format (type + data) that was incompatible with
what we were using everywhere else.
This just fixes that code duplication.
Signed-off-by: Luke Kanies <luke@puppetlabs.com>