summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2008-06-16 23:41:33 -0500
committerLuke Kanies <luke@madstop.com>2008-06-16 23:46:06 -0500
commit4d9536418d8f684923063eac03d3a59d69bb3794 (patch)
tree1225c14b60e61989eafee80614f40db1af12b868
parent543181272da492755e9219530d17f76a63faffef (diff)
downloadpuppet-4d9536418d8f684923063eac03d3a59d69bb3794.tar.gz
puppet-4d9536418d8f684923063eac03d3a59d69bb3794.tar.xz
puppet-4d9536418d8f684923063eac03d3a59d69bb3794.zip
Fixed #1221 - aliases to titles now work for resources.
-rw-r--r--CHANGELOG2
-rw-r--r--lib/puppet/node/catalog.rb7
-rwxr-xr-xspec/unit/node/catalog.rb11
3 files changed, 16 insertions, 4 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 470071a1b..8c0007415 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,4 +1,6 @@
0.24.?
+ Fixed #1221 - aliases to titles now work for resources.
+
Fixed #1360 - allowdupe works on groups again.
Fixed #1369 - the init service provider now supports HP-UX.
diff --git a/lib/puppet/node/catalog.rb b/lib/puppet/node/catalog.rb
index 7d9a83795..720b3752d 100644
--- a/lib/puppet/node/catalog.rb
+++ b/lib/puppet/node/catalog.rb
@@ -88,8 +88,13 @@ class Puppet::Node::Catalog < Puppet::PGraph
resource.ref =~ /^(.+)\[/
newref = "%s[%s]" % [$1 || resource.class.name, name]
+
+ # LAK:NOTE It's important that we directly compare the references,
+ # because sometimes an alias is created before the resource is
+ # added to the catalog, so comparing inside the below if block
+ # isn't sufficient.
+ return if newref == resource.ref
if existing = @resource_table[newref]
- return if existing == resource
raise(ArgumentError, "Cannot alias %s to %s; resource %s already exists" % [resource.ref, name, newref])
end
@resource_table[newref] = resource
diff --git a/spec/unit/node/catalog.rb b/spec/unit/node/catalog.rb
index ff9ab6930..b4f1503da 100755
--- a/spec/unit/node/catalog.rb
+++ b/spec/unit/node/catalog.rb
@@ -345,9 +345,9 @@ end
describe Puppet::Node::Catalog, " when functioning as a resource container" do
before do
@catalog = Puppet::Node::Catalog.new("host")
- @one = stub 'resource1', :ref => "Me[one]", :catalog= => nil
- @two = stub 'resource2', :ref => "Me[two]", :catalog= => nil
- @dupe = stub 'resource3', :ref => "Me[one]", :catalog= => nil
+ @one = stub 'resource1', :ref => "Me[one]", :catalog= => nil, :title => "one"
+ @two = stub 'resource2', :ref => "Me[two]", :catalog= => nil, :title => "two"
+ @dupe = stub 'resource3', :ref => "Me[one]", :catalog= => nil, :title => "one"
end
it "should provide a method to add one or more resources" do
@@ -482,6 +482,11 @@ describe Puppet::Node::Catalog, " when functioning as a resource container" do
proc { @catalog.alias @one, "one" }.should_not raise_error
end
+ it "should not create aliases that point back to the resource" do
+ @catalog.alias(@one, "one")
+ @catalog.resource(:me, "one").should be_nil
+ end
+
it "should be able to look resources up by their aliases" do
@catalog.add_resource @one
@catalog.alias @one, "two"