[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. 2.6.5rc1-120-g2247c80

Dan Bode bodepd at gmail.com
Mon Feb 7 06:40:11 UTC 2011


The following commit has been merged in the upstream branch:
commit 87c5c30fe8d2bbc31dabeb7383f5e5703a732bc5
Author: Dan Bode <bodepd at gmail.com>
Date:   Tue Jan 11 20:00:32 2011 -0600

    (#5910) Improved logging when declared classes cannot be found:
    
    Previously, when a class could not be found, it was displaying the same error message as when a resource type could not be found. This resulted in confusing error message: Invalid resource type class, when really it should display the name of the class that could not be found.
    
    My patch changes the error message to:
    
    Could not find declared class #{title}

diff --git a/lib/puppet/resource.rb b/lib/puppet/resource.rb
index 4f0d507..6821e0e 100644
--- a/lib/puppet/resource.rb
+++ b/lib/puppet/resource.rb
@@ -201,8 +201,13 @@ class Puppet::Resource
     tag(self.title) if valid_tag?(self.title)
 
     @reference = Reference.new(@type, at title) # for serialization compatibility with 0.25.x
-
-    raise ArgumentError, "Invalid resource type #{type}" if strict? and ! resource_type
+    if strict? and ! resource_type
+      if @type == 'Class'
+        raise ArgumentError, "Could not find declared class #{title}"
+      else
+        raise ArgumentError, "Invalid resource type #{type}"
+      end
+    end
   end
 
   def ref
diff --git a/spec/unit/resource_spec.rb b/spec/unit/resource_spec.rb
index e65e8a1..11ff904 100755
--- a/spec/unit/resource_spec.rb
+++ b/spec/unit/resource_spec.rb
@@ -98,6 +98,14 @@ describe Puppet::Resource do
     lambda { Puppet::Resource.new("foo") }.should raise_error(ArgumentError)
   end
 
+  it 'should fail if strict is set and type does not exist' do
+    lambda { Puppet::Resource.new('foo', 'title', {:strict=>true}) }.should raise_error(ArgumentError, 'Invalid resource type foo') 
+  end
+
+  it 'should fail if strict is set and class does not exist' do
+    lambda { Puppet::Resource.new('Class', 'foo', {:strict=>true}) }.should raise_error(ArgumentError, 'Could not find declared class foo') 
+  end
+
   it "should fail if the title is a hash and the type is not a valid resource reference string" do
     lambda { Puppet::Resource.new({:type => "foo", :title => "bar"}) }.should raise_error(ArgumentError,
       'Puppet::Resource.new does not take a hash as the first argument. Did you mean ("foo", "bar") ?'

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list