From bd973a2eeb9cc161553b47974b3e88c3343e4ce3 Mon Sep 17 00:00:00 2001 From: Markus Roberts Date: Fri, 27 Aug 2010 16:00:21 -0700 Subject: Fix for #4637 --use of namevar missed in refactor A use of namevar apparently slipped through the net or got (re)introduced in a merge/conflict resolution. --- lib/puppet/application/describe.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/puppet/application/describe.rb b/lib/puppet/application/describe.rb index 5abe3ea14..e76b347f6 100644 --- a/lib/puppet/application/describe.rb +++ b/lib/puppet/application/describe.rb @@ -130,7 +130,7 @@ class TypeDoc a[0].to_s <=> b[0].to_s }.each { |name, doc| print "\n- **#{name}**" - if type.namevar == name and name != :name + if type.key_attributes.include?(name) and name != :name puts " (*namevar*)" else puts "" -- cgit From 14b33402812756dc0cd3e84619afa211d449d59f Mon Sep 17 00:00:00 2001 From: Markus Roberts Date: Fri, 10 Sep 2010 18:18:55 -0700 Subject: Fix for #4736 -- preserve case of defined resources This restricts the change introduced in #4691 to hostclasses, and leaves defined resources and nodes alone, thus more closely mimicing the 0.25.x behaviour. It also includes title, as this was similarly affected. --- lib/puppet/resource/type.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/puppet/resource/type.rb b/lib/puppet/resource/type.rb index 1d378aaa6..7b21e55dc 100644 --- a/lib/puppet/resource/type.rb +++ b/lib/puppet/resource/type.rb @@ -233,8 +233,13 @@ class Puppet::Resource::Type resource[param] = value end - scope.setvar("title", resource.title) unless set.include? :title - scope.setvar("name", resource.name.to_s.downcase) unless set.include? :name + if @type == :hostclass + scope.setvar("title", resource.title.to_s.downcase) unless set.include? :title + scope.setvar("name", resource.name.to_s.downcase ) unless set.include? :name + else + scope.setvar("title", resource.title ) unless set.include? :title + scope.setvar("name", resource.name ) unless set.include? :name + end scope.setvar("module_name", module_name) if module_name and ! set.include? :module_name if caller_name = scope.parent_module_name and ! set.include?(:caller_module_name) -- cgit From 9bdfe694bc6c60a48b45f8dd49c20c6da31445f7 Mon Sep 17 00:00:00 2001 From: James Cammarata Date: Sat, 11 Sep 2010 10:23:38 -0500 Subject: Fix for Bug #4756 - Providers no longer respect missing features Restored deleted lines from type.rb and reinstated unit tests --- lib/puppet/type.rb | 6 ++++++ spec/unit/type/service_spec.rb | 8 ++++++++ test/ral/manager/attributes.rb | 5 ++++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb index 291179a02..ccb2b492a 100644 --- a/lib/puppet/type.rb +++ b/lib/puppet/type.rb @@ -472,6 +472,12 @@ class Type raise Puppet::Error, "Resource type #{self.class.name} does not support parameter #{name}" end + if provider and ! provider.class.supports_parameter?(klass) + missing = klass.required_features.find_all { |f| ! provider.class.feature?(f) } + info "Provider %s does not support features %s; not managing attribute %s" % [provider.class.name, missing.join(", "), name] + return nil + end + return @parameters[name] if @parameters.include?(name) @parameters[name] = klass.new(:resource => self) diff --git a/spec/unit/type/service_spec.rb b/spec/unit/type/service_spec.rb index 0f4a50750..0958a69fa 100755 --- a/spec/unit/type/service_spec.rb +++ b/spec/unit/type/service_spec.rb @@ -76,10 +76,18 @@ describe Puppet::Type.type(:service), "when validating attribute values" do it "should allow setting the :enable parameter if the provider has the :enableable feature" do Puppet::Type.type(:service).defaultprovider.stubs(:supports_parameter?).returns(true) + Puppet::Type.type(:service).defaultprovider.expects(:supports_parameter?).with(Puppet::Type.type(:service).attrclass(:enable)).returns(true) svc = Puppet::Type.type(:service).new(:name => "yay", :enable => true) svc.should(:enable).should == :true end + it "should not allow setting the :enable parameter if the provider is missing the :enableable feature" do + Puppet::Type.type(:service).defaultprovider.stubs(:supports_parameter?).returns(true) + Puppet::Type.type(:service).defaultprovider.expects(:supports_parameter?).with(Puppet::Type.type(:service).attrclass(:enable)).returns(false) + svc = Puppet::Type.type(:service).new(:name => "yay", :enable => true) + svc.should(:enable).should be_nil + end + it "should split paths on ':'" do FileTest.stubs(:exist?).returns(true) FileTest.stubs(:directory?).returns(true) diff --git a/test/ral/manager/attributes.rb b/test/ral/manager/attributes.rb index 74a4d0708..6d0284d9e 100755 --- a/test/ral/manager/attributes.rb +++ b/test/ral/manager/attributes.rb @@ -229,7 +229,10 @@ class TestTypeAttributes < Test::Unit::TestCase end yes.each { |a| assert(resource.should(a), "Did not get value for #{a} in #{prov.name}") } no.each do |a| - # These may or may not get passed to the provider. We shouldn't care. + assert_nil(resource.should(a), "Got value for unsupported %s in %s" % [a, prov.name]) + if Puppet::Util::Log.sendlevel?(:info) + assert(@logs.find { |l| l.message =~ /not managing attribute #{a}/ and l.level == :info }, "No warning about failed %s" % a) + end end @logs.clear -- cgit From 14f871d6a9cad5c3eda10da005a97ed8aba9e991 Mon Sep 17 00:00:00 2001 From: Jesse Wolfe Date: Mon, 13 Sep 2010 18:11:31 -0700 Subject: [#4756] addendum for #4756 This fixes spec and unit tests indirectly related to the previous patch-revert. One failure was from trying to test the User Type's roles, when, on many platforms, the roles feature wasn't supported by the default Provider. Other tests could fail on some platforms because they assumed that unsupported attributes would be ignored with a warning, but the code was crashing instead. --- lib/puppet/type.rb | 16 +++++++++------- spec/unit/type/user_spec.rb | 5 +++++ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb index ccb2b492a..f9aacece8 100644 --- a/lib/puppet/type.rb +++ b/lib/puppet/type.rb @@ -410,13 +410,15 @@ class Type property = self.newattr(name) - begin - # make sure the parameter doesn't have any errors - property.value = value - rescue => detail - error = Puppet::Error.new("Parameter #{name} failed: #{detail}") - error.set_backtrace(detail.backtrace) - raise error + if property + begin + # make sure the parameter doesn't have any errors + property.value = value + rescue => detail + error = Puppet::Error.new("Parameter #{name} failed: #{detail}") + error.set_backtrace(detail.backtrace) + raise error + end end nil diff --git a/spec/unit/type/user_spec.rb b/spec/unit/type/user_spec.rb index abe18933f..4c6eb1150 100755 --- a/spec/unit/type/user_spec.rb +++ b/spec/unit/type/user_spec.rb @@ -262,6 +262,11 @@ describe user do end describe "when user has roles" do + before do + # To test this feature, we have to support it. + user.new(:name => "foo").provider.class.stubs(:feature?).returns(true) + end + it "should autorequire roles" do testuser = Puppet::Type.type(:user).new(:name => "testuser") testuser[:roles] = "testrole" -- cgit From cad1e0f69ca19b37901f7f289444feae8f9ebd34 Mon Sep 17 00:00:00 2001 From: James Turnbull Date: Tue, 14 Sep 2010 11:49:40 +1000 Subject: Updated CHANGELOG for 2.6.1 --- CHANGELOG | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 6563fde82..d340d776f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,13 @@ +2.6.1 +===== +14f871d [#4756] addendum for #4756 +9bdfe69 Fix for Bug #4756 - Providers no longer respect missing features Restored deleted lines from type.rb and reinstated unit tests +14b3340 Fix for #4736 -- preserve case of defined resources +bd973a2 Fix for #4637 --use of namevar missed in refactor + 2.6.1rc4 ======== +efa834a Updated CHANGELOG for 2.6.1rc4 763e7cb Minimal fix for #4691 -- class name uppercased in $name 4a9c857 Fix for #4693 -- implicit stages should never be serialized fa4d32c Fix for #4646 -- Missing stub -- cgit