Fixing the :check metaparam so it does not try to check unsupported parameters
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2684 980ebf18-57e1-0310-9a29-db15c13687c0
This commit is contained in:
Родитель
f1462cb0d2
Коммит
edb1be2d75
|
@ -51,7 +51,14 @@ class Puppet::Type
|
|||
munge do |args|
|
||||
# If they've specified all, collect all known properties
|
||||
if args == :all
|
||||
args = @resource.class.properties.collect do |property|
|
||||
args = @resource.class.properties.find_all do |property|
|
||||
# Only get properties supported by our provider
|
||||
if @resource.provider
|
||||
@resource.provider.class.supports_parameter?(property)
|
||||
else
|
||||
true
|
||||
end
|
||||
end.collect do |property|
|
||||
property.name
|
||||
end
|
||||
end
|
||||
|
|
|
@ -252,10 +252,12 @@ class Type
|
|||
rescue ArgumentError, Puppet::Error, TypeError
|
||||
raise
|
||||
rescue => detail
|
||||
self.devfail(
|
||||
error = Puppet::DevError.new(
|
||||
"Could not set %s on %s: %s" %
|
||||
[attr, self.class.name, detail]
|
||||
)
|
||||
error.set_backtrace(detail.backtrace)
|
||||
raise error
|
||||
end
|
||||
hash.delete attr
|
||||
end
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
$:.unshift("../../lib") if __FILE__ =~ /\.rb$/
|
||||
|
||||
require 'puppettest'
|
||||
require 'mocha'
|
||||
|
||||
class TestTypeAttributes < Test::Unit::TestCase
|
||||
include PuppetTest
|
||||
|
@ -315,6 +316,37 @@ class TestTypeAttributes < Test::Unit::TestCase
|
|||
inst.value = :nosuchattr
|
||||
end
|
||||
end
|
||||
|
||||
def test_check_ignores_unsupported_params
|
||||
type = Puppet::Type.newtype(:unsupported) do
|
||||
feature :nosuchfeat, "testing"
|
||||
newparam(:name) {}
|
||||
newproperty(:yep) {}
|
||||
newproperty(:nope, :required_features => :nosuchfeat) {}
|
||||
end
|
||||
$yep = :absent
|
||||
type.provide(:only) do
|
||||
def self.supports_parameter?(param)
|
||||
if param.name == :nope
|
||||
return false
|
||||
else
|
||||
return true
|
||||
end
|
||||
end
|
||||
|
||||
def yep
|
||||
$yep
|
||||
end
|
||||
def yep=(v)
|
||||
$yep = v
|
||||
end
|
||||
end
|
||||
cleanup { Puppet::Type.rmtype(:unsupported) }
|
||||
|
||||
obj = type.create(:name => "test", :check => :yep)
|
||||
obj.expects(:newattr).with(:nope).never
|
||||
obj[:check] = :all
|
||||
end
|
||||
end
|
||||
|
||||
# $Id$
|
||||
|
|
Загрузка…
Ссылка в новой задаче