diff options
author | Paul Berry <paul@puppetlabs.com> | 2010-08-13 15:25:17 -0700 |
---|---|---|
committer | Paul Berry <paul@puppetlabs.com> | 2010-08-13 15:53:29 -0700 |
commit | caca187dffbd6e628d7eda599c7f2939dd05fafc (patch) | |
tree | 3bda82a89dd30d9612a229ac3b38588df146b50a /lib | |
parent | 6b1dd81799a44288287d9ab0cdf46afa3aaf090a (diff) | |
download | puppet-caca187dffbd6e628d7eda599c7f2939dd05fafc.tar.gz puppet-caca187dffbd6e628d7eda599c7f2939dd05fafc.tar.xz puppet-caca187dffbd6e628d7eda599c7f2939dd05fafc.zip |
Moved perform_initial_import from Puppet::Resource::TypeCollection to Puppet::Node::Environment.
This change is part of an ongoing effort to remove functionality from
TypeCollection that is not related to keeping track of a collection of
types. This reduces TypeCollection's linkage to the environment,
which is a step toward decoupling it from the type loading mechanism.
Also, added a spec test to verify that TypeCollection.version is
correctly recomputed when types are re-imported.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/puppet/node/environment.rb | 22 | ||||
-rw-r--r-- | lib/puppet/resource/type_collection.rb | 18 |
2 files changed, 21 insertions, 19 deletions
diff --git a/lib/puppet/node/environment.rb b/lib/puppet/node/environment.rb index 3f67474f9..ad11a0476 100644 --- a/lib/puppet/node/environment.rb +++ b/lib/puppet/node/environment.rb @@ -81,7 +81,7 @@ class Puppet::Node::Environment Thread.current[:known_resource_types] ||= synchronize { if @known_resource_types.nil? or @known_resource_types.stale? @known_resource_types = Puppet::Resource::TypeCollection.new(self) - @known_resource_types.perform_initial_import + perform_initial_import end @known_resource_types } @@ -143,5 +143,25 @@ class Puppet::Node::Environment end end + private + + def perform_initial_import + return if Puppet.settings[:ignoreimport] + parser = Puppet::Parser::Parser.new(self) + if code = Puppet.settings.uninterpolated_value(:code, name.to_s) and code != "" + parser.string = code + else + file = Puppet.settings.value(:manifest, name.to_s) + return unless File.exist?(file) + parser.file = file + end + parser.parse + rescue => detail + msg = "Could not parse for environment #{self}: #{detail}" + error = Puppet::Error.new(msg) + error.set_backtrace(detail.backtrace) + raise error + end + @root = new(:'*root*') end diff --git a/lib/puppet/resource/type_collection.rb b/lib/puppet/resource/type_collection.rb index 3a327e264..4254b037e 100644 --- a/lib/puppet/resource/type_collection.rb +++ b/lib/puppet/resource/type_collection.rb @@ -110,24 +110,6 @@ class Puppet::Resource::TypeCollection end end - def perform_initial_import - return if Puppet.settings[:ignoreimport] - parser = Puppet::Parser::Parser.new(environment) - if code = Puppet.settings.uninterpolated_value(:code, environment.to_s) and code != "" - parser.string = code - else - file = Puppet.settings.value(:manifest, environment.to_s) - return unless File.exist?(file) - parser.file = file - end - parser.parse - rescue => detail - msg = "Could not parse for environment #{environment}: #{detail}" - error = Puppet::Error.new(msg) - error.set_backtrace(detail.backtrace) - raise error - end - def stale? @watched_files.values.detect { |file| file.changed? } end |