summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2007-12-18 16:47:36 -0600
committerLuke Kanies <luke@madstop.com>2007-12-18 16:47:36 -0600
commit92b0ebc7b74a29b5b875fc104a3681a264d49f03 (patch)
tree2badd88f2b14f1669613a924bc79184e3c2359f3
parent1ada24d4d4aa9ccd9a37176aa3d105ec9874d208 (diff)
downloadpuppet-92b0ebc7b74a29b5b875fc104a3681a264d49f03.tar.gz
puppet-92b0ebc7b74a29b5b875fc104a3681a264d49f03.tar.xz
puppet-92b0ebc7b74a29b5b875fc104a3681a264d49f03.zip
Fixing #967 -- relationships now work when running 0.23.x clients
against 0.24.0 servers.
-rw-r--r--CHANGELOG4
-rw-r--r--lib/puppet/parser/resource/reference.rb8
-rwxr-xr-xspec/unit/parser/resource/reference.rb9
-rwxr-xr-xtest/language/resource.rb10
4 files changed, 23 insertions, 8 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 275e52f08..bf563dbce 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,7 @@
+ Fixed a backward compatibility issue when running 0.23.x
+ clients against 0.24.0 servers -- relationships would
+ consistently not work. (#967)
+
Closing existing http connections when opening a new one,
and closing all connections after each run. (#961)
diff --git a/lib/puppet/parser/resource/reference.rb b/lib/puppet/parser/resource/reference.rb
index 1dd816093..6e70d23b7 100644
--- a/lib/puppet/parser/resource/reference.rb
+++ b/lib/puppet/parser/resource/reference.rb
@@ -62,7 +62,13 @@ class Puppet::Parser::Resource::Reference < Puppet::ResourceReference
end
def to_ref
- return [type.to_s,title.to_s]
+ # We have to return different cases to provide backward compatibility
+ # from 0.24.x to 0.23.x.
+ if builtin?
+ return [type.to_s.downcase, title.to_s]
+ else
+ return [type.to_s, title.to_s]
+ end
end
def typeclass
diff --git a/spec/unit/parser/resource/reference.rb b/spec/unit/parser/resource/reference.rb
index 24b70d088..e7385f796 100755
--- a/spec/unit/parser/resource/reference.rb
+++ b/spec/unit/parser/resource/reference.rb
@@ -21,9 +21,14 @@ describe Puppet::Parser::Resource::Reference do
ref.builtintype.should equal(Puppet::Type.type(:file))
end
- it "should return a relationship-style resource reference when asked" do
+ it "should return a downcased relationship-style resource reference for defined types" do
ref = @type.new(:type => "file", :title => "/tmp/yay")
- ref.to_ref.should == ["File", "/tmp/yay"]
+ ref.to_ref.should == ["file", "/tmp/yay"]
+ end
+
+ it "should return a capitalized relationship-style resource reference for defined types" do
+ ref = @type.new(:type => "whatever", :title => "/tmp/yay")
+ ref.to_ref.should == ["Whatever", "/tmp/yay"]
end
it "should return a resource reference string when asked" do
diff --git a/test/language/resource.rb b/test/language/resource.rb
index 9c030d34a..84a30b029 100755
--- a/test/language/resource.rb
+++ b/test/language/resource.rb
@@ -239,9 +239,9 @@ class TestResource < PuppetTest::TestCase
assert_equal("nobody", obj["owner"], "Single-value string was not passed correctly")
assert_equal(%w{you me}, obj["group"], "Array of strings was not passed correctly")
assert_equal("svn", obj["ignore"], "Array with single string was not turned into single value")
- assert_equal(["File", refs[0].title], obj["require"], "Resource reference was not passed correctly")
- assert_equal([["File", refs[1].title], ["File", refs[2].title]], obj["subscribe"], "Array of resource references was not passed correctly")
- assert_equal(["File", refs[3].title], obj["notify"], "Array with single resource reference was not turned into single value")
+ assert_equal(["file", refs[0].title], obj["require"], "Resource reference was not passed correctly")
+ assert_equal([["file", refs[1].title], ["file", refs[2].title]], obj["subscribe"], "Array of resource references was not passed correctly")
+ assert_equal(["file", refs[3].title], obj["notify"], "Array with single resource reference was not turned into single value")
end
# FIXME This isn't a great test, but I need to move on.
@@ -332,7 +332,7 @@ class TestResource < PuppetTest::TestCase
end
assert_instance_of(Array, trans["require"])
- assert_equal(["File", "/tmp/ref1"], trans["require"])
+ assert_equal(["file", "/tmp/ref1"], trans["require"])
# Now try it when using an array of references.
two = Parser::Resource::Reference.new(:type => "file", :title => "/tmp/ref2")
@@ -348,7 +348,7 @@ class TestResource < PuppetTest::TestCase
assert_instance_of(Array, trans["require"][0])
trans["require"].each do |val|
assert_instance_of(Array, val)
- assert_equal("File", val[0])
+ assert_equal("file", val[0])
assert(val[1] =~ /\/tmp\/ref[0-9]/,
"Was %s instead of the file name" % val[1])
end