summaryrefslogtreecommitdiffstats
path: root/lib/puppet/parser
diff options
context:
space:
mode:
authorLuke Kanies <luke@puppetlabs.com>2011-07-05 12:25:54 -0700
committerLuke Kanies <luke@puppetlabs.com>2011-07-15 11:52:31 -0700
commitbaf32de1dcda02f7da8b2926abee7f46d0d47fe1 (patch)
tree88143812fff1b303034b8ff8e7697604c505c72f /lib/puppet/parser
parent2431bb3fc8fba238cb2cf1bb71f316c62ba384b7 (diff)
downloadpuppet-baf32de1dcda02f7da8b2926abee7f46d0d47fe1.tar.gz
puppet-baf32de1dcda02f7da8b2926abee7f46d0d47fe1.tar.xz
puppet-baf32de1dcda02f7da8b2926abee7f46d0d47fe1.zip
Making the Functions module more resilient
We were previously storing the module name with the environment instances as the key, which meant if the environment instances were removed, we could never get those modules again. Given that the functions weren't reloaded, this meant the functions were gone if we ever reloaded the environment. This makes the Functions environment module resilient across environment reloads, and it also makes the method work correctly when handed either an environment or a string. Signed-off-by: Luke Kanies <luke@puppetlabs.com> Reviewed-by: Nick Lewis <nick@puppetlabs.com>
Diffstat (limited to 'lib/puppet/parser')
-rw-r--r--lib/puppet/parser/functions.rb5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/puppet/parser/functions.rb b/lib/puppet/parser/functions.rb
index e19ac127f..22eee70d7 100644
--- a/lib/puppet/parser/functions.rb
+++ b/lib/puppet/parser/functions.rb
@@ -29,8 +29,11 @@ module Puppet::Parser::Functions
Environment = Puppet::Node::Environment
def self.environment_module(env = nil)
+ if env and ! env.is_a?(Puppet::Node::Environment)
+ env = Puppet::Node::Environment.new(env)
+ end
@modules.synchronize {
- @modules[ env || Environment.current || Environment.root ] ||= Module.new
+ @modules[ (env || Environment.current || Environment.root).name ] ||= Module.new
}
end