diff options
author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-01-12 03:20:29 +0000 |
---|---|---|
committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-01-12 03:20:29 +0000 |
commit | 21410a2152d03d8a7f52bebcdf52666e77a0dbfa (patch) | |
tree | 53ecc3ac66e46372ce36c90be5fb31d7a5f23872 | |
parent | 29b00fb744d2e27f835d0130b88ed4bda08c63f7 (diff) | |
download | puppet-21410a2152d03d8a7f52bebcdf52666e77a0dbfa.tar.gz puppet-21410a2152d03d8a7f52bebcdf52666e77a0dbfa.tar.xz puppet-21410a2152d03d8a7f52bebcdf52666e77a0dbfa.zip |
Fixing documentation generation, and fixing aliasing so that objects can safely be aliased to themselves
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@807 980ebf18-57e1-0310-9a29-db15c13687c0
-rw-r--r-- | lib/puppet/type.rb | 20 | ||||
-rw-r--r-- | test/types/type.rb | 18 |
2 files changed, 29 insertions, 9 deletions
diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb index c061380bd..135b3b427 100644 --- a/lib/puppet/type.rb +++ b/lib/puppet/type.rb @@ -201,7 +201,7 @@ class Type < Puppet::Element if @objects.has_key?(name) and self.isomorphic? raise Puppet::Error.new( "Object '%s' of type '%s' already exists with id '%s' vs. '%s'" % - [name,newobj.class.name, + [name, newobj.class.name, @objects[name].object_id,newobj.object_id] ) else @@ -353,6 +353,10 @@ class Type < Puppet::Element @@metaparams.each { |p| @@metaparamhash[name] = p } end + def self.eachmetaparam + @@metaparams.each { |p| yield p.name } + end + # Create a new parameter. Requires a block and a name, stores it in the # @parameters array, and does some basic checking on it. def self.newparam(name, &block) @@ -1480,10 +1484,10 @@ class Type < Puppet::Element # Documentation methods def self.paramdoc(param) - @paramdoc[param] + @paramhash[param].doc end def self.metaparamdoc(metaparam) - @@metaparamdoc[metaparam] + @@metaparamhash[metaparam].doc end # Add all of the meta parameters. @@ -1592,12 +1596,20 @@ class Type < Puppet::Element you are creating long commands using exec or when many different systems call a given package different names." - munge do |*aliases| + munge do |aliases| unless aliases.is_a?(Array) aliases = [aliases] end @parent.info "Adding aliases %s" % aliases.join(", ") aliases.each do |other| + if obj = @parent.class[other] + unless obj == @parent + raise Puppet::Error, + "%s an not create alias %s: object already exists" % + [@parent.name, other] + end + next + end @parent.class[other] = @parent end end diff --git a/test/types/type.rb b/test/types/type.rb index 6271fa43c..7a95e2574 100644 --- a/test/types/type.rb +++ b/test/types/type.rb @@ -135,11 +135,19 @@ class TestType < Test::Unit::TestCase def test_aliasing file = tempfile() - baseobj = Puppet.type(:file).create( - :name => file, - :create => true, - :alias => "funtest" - ) + baseobj = nil + assert_nothing_raised { + baseobj = Puppet.type(:file).create( + :name => file, + :create => true, + :alias => ["funtest"] + ) + } + + # Verify we adding ourselves as an alias isn't an error. + assert_nothing_raised { + baseobj[:alias] = file + } assert_instance_of(Puppet.type(:file), Puppet.type(:file)["funtest"], "Could not retrieve alias") |