It has been replaced with Puppet::Type.parameter_type. Note that the old method would produce ':param' and ':metaparam', and the new one produces ':parameter' and ':metaparameter'.
Signed-off-by: Luke Kanies <[email protected]> --- Local-branch: refactor/master/8233-refactor_parameter_management lib/puppet/type.rb | 8 +------- lib/puppet/type/zone.rb | 2 +- spec/unit/type/cron_spec.rb | 4 ++-- spec/unit/type/file_spec.rb | 4 ++-- spec/unit/type/filebucket_spec.rb | 2 +- spec/unit/type/group_spec.rb | 4 ++-- spec/unit/type/host_spec.rb | 4 ++-- spec/unit/type/interface_spec.rb | 4 ++-- spec/unit/type/mount_spec.rb | 4 ++-- spec/unit/type/package_spec.rb | 4 ++-- spec/unit/type/selboolean_spec.rb | 4 ++-- spec/unit/type/selmodule_spec.rb | 4 ++-- spec/unit/type/service_spec.rb | 4 ++-- spec/unit/type/ssh_authorized_key_spec.rb | 8 ++++---- spec/unit/type/sshkey_spec.rb | 4 ++-- spec/unit/type/vlan_spec.rb | 4 ++-- spec/unit/type_spec.rb | 8 ++++++++ test/lib/puppettest/fakes.rb | 4 ++-- test/ral/manager/attributes.rb | 10 +++++----- 19 files changed, 46 insertions(+), 44 deletions(-) diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb index 529c664..15bb6e2 100644 --- a/lib/puppet/type.rb +++ b/lib/puppet/type.rb @@ -244,7 +244,7 @@ class Type # This method is used in both Puppet::Type and Puppet::Resource. def self.valid_parameter?(name) name = name.to_sym - return true if name == :name + return true if name == :name and self != Puppet::Type return true if parameter(name) return false end @@ -278,12 +278,6 @@ class Type parameters.find_all { |p| p.property? } end - # What type of parameter are we dealing with? Cache the results, because - # this method gets called so many times. - def self.attrtype(attr) - parameter_type(attr) - end - def self.eachmetaparam parameters.each { |p| yield p.name } end diff --git a/lib/puppet/type/zone.rb b/lib/puppet/type/zone.rb index 0fc702c..528a123 100644 --- a/lib/puppet/type/zone.rb +++ b/lib/puppet/type/zone.rb @@ -475,7 +475,7 @@ Puppet::Type.newtype(:zone) do prophash = {} hash.each do |param, value| next if param == :name - case self.class.attrtype(param) + case self.class.parameter_type(param) when :property # Only try to provide values for the properties we're managing if prop = self.property(param) diff --git a/spec/unit/type/cron_spec.rb b/spec/unit/type/cron_spec.rb index 0fec370..6d566ae 100755 --- a/spec/unit/type/cron_spec.rb +++ b/spec/unit/type/cron_spec.rb @@ -25,13 +25,13 @@ describe Puppet::Type.type(:cron) do [:name, :provider].each do |param| it "should have a #{param} parameter" do - @class.attrtype(param).should == :param + @class.parameter_type(param).should == :parameter end end [:command, :special, :minute, :hour, :weekday, :month, :monthday, :environment, :user, :target].each do |property| it "should have a #{property} property" do - @class.attrtype(property).should == :property + @class.parameter_type(property).should == :property end end diff --git a/spec/unit/type/file_spec.rb b/spec/unit/type/file_spec.rb index 3a01d09..65c2347 100755 --- a/spec/unit/type/file_spec.rb +++ b/spec/unit/type/file_spec.rb @@ -419,13 +419,13 @@ describe Puppet::Type.type(:file) do describe "when validating attributes" do %w{path checksum backup recurse recurselimit source replace force ignore links purge sourceselect}.each do |attr| it "should have a '#{attr}' parameter" do - Puppet::Type.type(:file).attrtype(attr.intern).should == :param + Puppet::Type.type(:file).parameter_type(attr.intern).should == :parameter end end %w{content target ensure owner group mode type}.each do |attr| it "should have a '#{attr}' property" do - Puppet::Type.type(:file).attrtype(attr.intern).should == :property + Puppet::Type.type(:file).parameter_type(attr.intern).should == :property end end diff --git a/spec/unit/type/filebucket_spec.rb b/spec/unit/type/filebucket_spec.rb index 3c53111..f0a4906 100755 --- a/spec/unit/type/filebucket_spec.rb +++ b/spec/unit/type/filebucket_spec.rb @@ -5,7 +5,7 @@ describe Puppet::Type.type(:filebucket) do describe "when validating attributes" do %w{name server port path}.each do |attr| it "should have a '#{attr}' parameter" do - Puppet::Type.type(:filebucket).attrtype(attr.intern).should == :param + Puppet::Type.type(:filebucket).parameter_type(attr.intern).should == :parameter end end diff --git a/spec/unit/type/group_spec.rb b/spec/unit/type/group_spec.rb index afe2824..d57e2a2 100755 --- a/spec/unit/type/group_spec.rb +++ b/spec/unit/type/group_spec.rb @@ -22,13 +22,13 @@ describe Puppet::Type.type(:group) do describe "when validating attributes" do [:name, :allowdupe].each do |param| it "should have a #{param} parameter" do - @class.attrtype(param).should == :param + @class.parameter_type(param).should == :parameter end end [:ensure, :gid].each do |param| it "should have a #{param} property" do - @class.attrtype(param).should == :property + @class.parameter_type(param).should == :property end end diff --git a/spec/unit/type/host_spec.rb b/spec/unit/type/host_spec.rb index 8c73a82..3a86c5e 100755 --- a/spec/unit/type/host_spec.rb +++ b/spec/unit/type/host_spec.rb @@ -18,13 +18,13 @@ describe host do describe "when validating attributes" do [:name, :provider ].each do |param| it "should have a #{param} parameter" do - @class.attrtype(param).should == :param + @class.parameter_type(param).should == :parameter end end [:ip, :target, :host_aliases, :comment, :ensure].each do |property| it "should have a #{property} property" do - @class.attrtype(property).should == :property + @class.parameter_type(property).should == :property end end diff --git a/spec/unit/type/interface_spec.rb b/spec/unit/type/interface_spec.rb index 74e3257..5db40b1 100755 --- a/spec/unit/type/interface_spec.rb +++ b/spec/unit/type/interface_spec.rb @@ -12,7 +12,7 @@ describe Puppet::Type.type(:interface) do end it "should have an ensure property" do - Puppet::Type.type(:interface).attrtype(:ensure).should == :property + Puppet::Type.type(:interface).parameter_type(:ensure).should == :property end it "should be applied on device" do @@ -21,7 +21,7 @@ describe Puppet::Type.type(:interface) do [:description, :speed, :duplex, :native_vlan, :encapsulation, :mode, :allowed_trunk_vlans, :etherchannel, :ipaddress].each do |p| it "should have a #{p} property" do - Puppet::Type.type(:interface).attrtype(p).should == :property + Puppet::Type.type(:interface).parameter_type(p).should == :property end end diff --git a/spec/unit/type/mount_spec.rb b/spec/unit/type/mount_spec.rb index 9ef7699..3be3e3c 100755 --- a/spec/unit/type/mount_spec.rb +++ b/spec/unit/type/mount_spec.rb @@ -19,13 +19,13 @@ end describe Puppet::Type.type(:mount), "when validating attributes" do [:name, :remounts, :provider].each do |param| it "should have a #{param} parameter" do - Puppet::Type.type(:mount).attrtype(param).should == :param + Puppet::Type.type(:mount).parameter_type(param).should == :parameter end end [:ensure, :device, :blockdevice, :fstype, :options, :pass, :dump, :atboot, :target].each do |param| it "should have a #{param} property" do - Puppet::Type.type(:mount).attrtype(param).should == :property + Puppet::Type.type(:mount).parameter_type(param).should == :property end end end diff --git a/spec/unit/type/package_spec.rb b/spec/unit/type/package_spec.rb index e75f7d2..21f0bda 100755 --- a/spec/unit/type/package_spec.rb +++ b/spec/unit/type/package_spec.rb @@ -34,12 +34,12 @@ describe Puppet::Type.type(:package) do describe "when validating attributes" do [:name, :source, :instance, :status, :adminfile, :responsefile, :configfiles, :category, :platform, :root, :vendor, :description, :allowcdrom].each do |param| it "should have a #{param} parameter" do - Puppet::Type.type(:package).attrtype(param).should == :param + Puppet::Type.type(:package).parameter_type(param).should == :parameter end end it "should have an ensure property" do - Puppet::Type.type(:package).attrtype(:ensure).should == :property + Puppet::Type.type(:package).parameter_type(:ensure).should == :property end end diff --git a/spec/unit/type/selboolean_spec.rb b/spec/unit/type/selboolean_spec.rb index aa495af..28ec726 100755 --- a/spec/unit/type/selboolean_spec.rb +++ b/spec/unit/type/selboolean_spec.rb @@ -4,12 +4,12 @@ require 'spec_helper' describe Puppet::Type.type(:selboolean), "when validating attributes" do [:name, :persistent].each do |param| it "should have a #{param} parameter" do - Puppet::Type.type(:selboolean).attrtype(param).should == :param + Puppet::Type.type(:selboolean).parameter_type(param).should == :parameter end end it "should have a value property" do - Puppet::Type.type(:selboolean).attrtype(:value).should == :property + Puppet::Type.type(:selboolean).parameter_type(:value).should == :property end end diff --git a/spec/unit/type/selmodule_spec.rb b/spec/unit/type/selmodule_spec.rb index c067de0..5b8d6f2 100755 --- a/spec/unit/type/selmodule_spec.rb +++ b/spec/unit/type/selmodule_spec.rb @@ -4,13 +4,13 @@ require 'spec_helper' describe Puppet::Type.type(:selmodule), "when validating attributes" do [:name, :selmoduledir, :selmodulepath].each do |param| it "should have a #{param} parameter" do - Puppet::Type.type(:selmodule).attrtype(param).should == :param + Puppet::Type.type(:selmodule).parameter_type(param).should == :parameter end end [:ensure, :syncversion].each do |param| it "should have a #{param} property" do - Puppet::Type.type(:selmodule).attrtype(param).should == :property + Puppet::Type.type(:selmodule).parameter_type(param).should == :property end end end diff --git a/spec/unit/type/service_spec.rb b/spec/unit/type/service_spec.rb index 426bc64..9e52c45 100755 --- a/spec/unit/type/service_spec.rb +++ b/spec/unit/type/service_spec.rb @@ -14,13 +14,13 @@ end describe Puppet::Type.type(:service), "when validating attributes" do [:name, :binary, :hasstatus, :path, :pattern, :start, :restart, :stop, :status, :hasrestart, :control].each do |param| it "should have a #{param} parameter" do - Puppet::Type.type(:service).attrtype(param).should == :param + Puppet::Type.type(:service).parameter_type(param).should == :parameter end end [:ensure, :enable].each do |param| it "should have an #{param} property" do - Puppet::Type.type(:service).attrtype(param).should == :property + Puppet::Type.type(:service).parameter_type(param).should == :property end end end diff --git a/spec/unit/type/ssh_authorized_key_spec.rb b/spec/unit/type/ssh_authorized_key_spec.rb index 71b8a9a..716ab0f 100755 --- a/spec/unit/type/ssh_authorized_key_spec.rb +++ b/spec/unit/type/ssh_authorized_key_spec.rb @@ -24,13 +24,13 @@ describe ssh_authorized_key do [:name, :provider].each do |param| it "should have a #{param} parameter" do - @class.attrtype(param).should == :param + @class.parameter_type(param).should == :parameter end end [:type, :key, :user, :target, :options, :ensure].each do |property| it "should have a #{property} property" do - @class.attrtype(property).should == :property + @class.parameter_type(property).should == :property end end @@ -229,7 +229,7 @@ describe ssh_authorized_key do describe "when user is specified" do it "should determine target" do - resource = @class.create( + resource = @class.new( :name => "Test", :user => "root" ) @@ -249,7 +249,7 @@ describe ssh_authorized_key do describe "when calling validate" do it "should not crash on a non-existant user" do - resource = @class.create( + resource = @class.new( :name => "Test", :user => "ihopesuchuserdoesnotexist" ) diff --git a/spec/unit/type/sshkey_spec.rb b/spec/unit/type/sshkey_spec.rb index ba34069..504db73 100755 --- a/spec/unit/type/sshkey_spec.rb +++ b/spec/unit/type/sshkey_spec.rb @@ -15,13 +15,13 @@ describe sshkey do describe "when validating attributes" do [:name, :provider].each do |param| it "should have a #{param} parameter" do - @class.attrtype(param).should == :param + @class.parameter_type(param).should == :parameter end end [:host_aliases, :ensure, :key, :type].each do |property| it "should have a #{property} property" do - @class.attrtype(property).should == :property + @class.parameter_type(property).should == :property end end end diff --git a/spec/unit/type/vlan_spec.rb b/spec/unit/type/vlan_spec.rb index 7d7a0b1..6932ebe 100755 --- a/spec/unit/type/vlan_spec.rb +++ b/spec/unit/type/vlan_spec.rb @@ -16,11 +16,11 @@ describe Puppet::Type.type(:vlan) do end it "should have an ensure property" do - Puppet::Type.type(:vlan).attrtype(:ensure).should == :property + Puppet::Type.type(:vlan).parameter_type(:ensure).should == :property end it "should have a description property" do - Puppet::Type.type(:vlan).attrtype(:description).should == :property + Puppet::Type.type(:vlan).parameter_type(:description).should == :property end describe "when validating attribute values" do diff --git a/spec/unit/type_spec.rb b/spec/unit/type_spec.rb index 3703832..7dd091d 100755 --- a/spec/unit/type_spec.rb +++ b/spec/unit/type_spec.rb @@ -261,6 +261,14 @@ describe Puppet::Type do @type.newparam(:foo) @type.should be_valid_parameter("foo") end + + it "should always consider :name to be a valid parameter" do + @type.should be_valid_parameter(:name) + end + + it "should not consider :name to be a valid metaparameter" do + Puppet::Type.should_not be_metaparam(:name) + end end describe "when creating an event" do diff --git a/test/lib/puppettest/fakes.rb b/test/lib/puppettest/fakes.rb index 712332b..40ec549 100644 --- a/test/lib/puppettest/fakes.rb +++ b/test/lib/puppettest/fakes.rb @@ -26,7 +26,7 @@ module PuppetTest end def [](param) - if @realresource.attrtype(param) == :property + if @realresource.parameter_type(param) == :property @is[param] else @params[param] @@ -36,7 +36,7 @@ module PuppetTest def []=(param, value) param = symbolize(param) raise Puppet::DevError, "Invalid attribute #{param} for #{@realresource.name}" unless @realresource.valid_parameter?(param) - if @realresource.attrtype(param) == :property + if @realresource.parameter_type(param) == :property @should[param] = value else @params[param] = value diff --git a/test/ral/manager/attributes.rb b/test/ral/manager/attributes.rb index 12d9987..04876ce 100755 --- a/test/ral/manager/attributes.rb +++ b/test/ral/manager/attributes.rb @@ -206,18 +206,18 @@ class TestTypeAttributes < Test::Unit::TestCase resource = file.new(:path => tempfile) inst = klass.new(:resource => resource) - {:property => [:owner, :group], :parameter => [:ignore, :recurse], :metaparam => [:require, :subscribe]}.each do |attrtype, attrs| - assert_nothing_raised("Could not set check to a single #{attrtype} value") do + {:property => [:owner, :group], :parameter => [:ignore, :recurse], :metaparam => [:require, :subscribe]}.each do |parameter_type, attrs| + assert_nothing_raised("Could not set check to a single #{parameter_type} value") do inst.value = attrs[0] end - if attrtype == :property + if parameter_type == :property assert(resource.property(attrs[0]), "Check did not create property instance during single check") end - assert_nothing_raised("Could not set check to multiple #{attrtype} values") do + assert_nothing_raised("Could not set check to multiple #{parameter_type} values") do inst.value = attrs end - if attrtype == :property + if parameter_type == :property assert(resource.property(attrs[1]), "Check did not create property instance during multiple check") end end -- 1.7.3.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.
