summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG8
-rw-r--r--lib/puppet/application/describe.rb2
-rw-r--r--lib/puppet/resource/type.rb9
-rw-r--r--lib/puppet/type.rb22
-rwxr-xr-xspec/unit/type/service_spec.rb8
-rwxr-xr-xspec/unit/type/user_spec.rb5
-rwxr-xr-xtest/ral/manager/attributes.rb5
7 files changed, 48 insertions, 11 deletions
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
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 ""
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)
diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb
index 291179a02..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
@@ -472,6 +474,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/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"
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