Requiring puppet before the run_mode has been set by the application
causes the default run_mode of 'user' to be set instead of what the
application wants.  This leads to the incorrect default settings to be
used, which lead to inspect not being able to properly retrieve file
metadata from a fileserver.

Reviewed-by: Max Martin <[email protected]>
Signed-off-by: Matt Robinson <[email protected]>
---
 lib/puppet/application/inspect.rb     |    7 +++++--
 spec/unit/application/inspect_spec.rb |    5 +++++
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/lib/puppet/application/inspect.rb 
b/lib/puppet/application/inspect.rb
index ce32c66..2260fee 100644
--- a/lib/puppet/application/inspect.rb
+++ b/lib/puppet/application/inspect.rb
@@ -1,6 +1,4 @@
-require 'puppet'
 require 'puppet/application'
-require 'puppet/file_bucket/dipper'
 
 class Puppet::Application::Inspect < Puppet::Application
 
@@ -97,6 +95,11 @@ Licensed under the GNU General Public License version 2
     Puppet::Resource::Catalog.terminus_class = :yaml
   end
 
+  def preinit
+    require 'puppet'
+    require 'puppet/file_bucket/dipper'
+  end
+
   def run_command
     benchmark(:notice, "Finished inspection") do
       retrieval_starttime = Time.now
diff --git a/spec/unit/application/inspect_spec.rb 
b/spec/unit/application/inspect_spec.rb
index d334a87..637a95d 100755
--- a/spec/unit/application/inspect_spec.rb
+++ b/spec/unit/application/inspect_spec.rb
@@ -13,6 +13,11 @@ describe Puppet::Application::Inspect do
 
   before :each do
     @inspect = Puppet::Application[:inspect]
+    @inspect.preinit
+  end
+
+  it "should operate in agent run_mode" do
+    @inspect.class.run_mode.name.should == :agent
   end
 
   describe "during setup" do
-- 
1.7.3.1

-- 
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