Looks like a +1.
On Mar 21, 2010, at 4:10 AM, Brice Figureau wrote:
Hi,
Here is a fix for #3186 (which was hard to find, so many kudos to Alan
Harder who was able to find the root issue).
Please review as usual.
I think we should apply this patch to 0.25.x (which it is based on)
so that it
is available in 0.25.5 when we do it.
Thanks,
Brice
Original commit msg:
Due to the fact that resource.set_parameter is overwriting the
previous
set_parameters, we were losing the previous relationships we set
there,
either in a previous call of require or in the same call.
Signed-off-by: Brice Figureau <[email protected]>
---
lib/puppet/parser/functions/require.rb | 2 +-
spec/integration/parser/functions/require.rb | 19 +++++++++++++++++
+-
spec/unit/parser/functions/require.rb | 14 ++++++++++++--
3 files changed, 31 insertions(+), 4 deletions(-)
diff --git a/lib/puppet/parser/functions/require.rb b/lib/puppet/
parser/functions/require.rb
index 3e79619..f634f9f 100644
--- a/lib/puppet/parser/functions/require.rb
+++ b/lib/puppet/parser/functions/require.rb
@@ -50,7 +50,7 @@ fail if used with earlier clients.
# but that is considered a containment edge, not a
dependency
# edge, so it usually gets lost on the client.
ref = Puppet::Parser::Resource::Reference.new(:type
=> :class, :title => klass)
- resource.set_parameter(:require, ref)
+ resource.set_parameter(:require,
[resource[:require]].flatten.compact << ref)
end
end
end
diff --git a/spec/integration/parser/functions/require.rb b/spec/
integration/parser/functions/require.rb
index 960594b..6f169ad 100755
--- a/spec/integration/parser/functions/require.rb
+++ b/spec/integration/parser/functions/require.rb
@@ -22,10 +22,27 @@ describe "the require function" do
@scope.function_require("requiredclass")
@scope.resource["require"].should_not be_nil
- ref = @scope.resource["require"]
+ ref = @scope.resource["require"].shift
ref.type.should == "Class"
ref.title.should == "requiredclass"
end
+
+ it "should queue relationships between the 'required' class and
our classes" do
+ @parser.newclass("requiredclass1")
+ @parser.newclass("requiredclass2")
+
+ @scope.function_require("requiredclass1")
+ @scope.function_require("requiredclass2")
+
+ @scope.resource["require"].should_not be_nil
+
+ (ref1,ref2) = @scope.resource["require"]
+ ref1.type.should == "Class"
+ ref1.title.should == "requiredclass1"
+ ref2.type.should == "Class"
+ ref2.title.should == "requiredclass2"
+ end
+
end
describe "the include function" do
diff --git a/spec/unit/parser/functions/require.rb b/spec/unit/
parser/functions/require.rb
index 532c069..4e05069 100755
--- a/spec/unit/parser/functions/require.rb
+++ b/spec/unit/parser/functions/require.rb
@@ -8,7 +8,7 @@ describe "the require function" do
@catalog = stub 'catalog'
@compiler = stub 'compiler', :catalog => @catalog
- @resource = stub 'resource', :set_parameter =>
nil, :metaparam_compatibility_mode? => false
+ @resource = stub 'resource', :set_parameter =>
nil, :metaparam_compatibility_mode? => false, :[] => nil
@scope = Puppet::Parser::Scope.new()
@scope.stubs(:resource).returns @resource
@scope.stubs(:findresource)
@@ -28,7 +28,7 @@ describe "the require function" do
end
it "should set the 'require' prarameter on the resource to a
resource reference" do
- @resource.expects(:set_parameter).with { |name, value| name
== :require and value.is_a?(Puppet::Parser::Resource::Reference) }
+ @resource.expects(:set_parameter).with { |name, value| name
== :require and value[0].is_a?(Puppet::Parser::Resource::Reference) }
@scope.stubs(:function_include)
@scope.function_require("myclass")
end
@@ -56,4 +56,14 @@ describe "the require function" do
@scope.function_require("myclass")
end
+
+ it "should append the required class to the require parameter" do
+ @scope.stubs(:function_include)
+
Puppet::Parser::Resource::Reference.stubs(:new).returns(:require2)
+
+ @resource.expects(:[]).with(:require).returns(:require1)
+ @resource.expects(:set_parameter).with(:require,
[:require1, :require2])
+
+ @scope.function_require("myclass")
+ end
end
--
1.6.6.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
.
--
Get forgiveness now -- tomorrow you may no longer feel guilty.
---------------------------------------------------------------------
Luke Kanies -|- http://reductivelabs.com -|- +1(615)594-8199
--
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.