Browse files

kdbkey ruby: add check metadata also to the resource key

This ensures, that the check can be performed even if the spec_key is
just created (in the same kdb.set operation).
Otherwise we could end up creating keys with invalid values
  • Loading branch information...
BernhardDenner committed Mar 24, 2017
1 parent dc22b90 commit bc4235d56dd8c7fa9cd36d3f40d1cb8063798747
Showing with 10 additions and 1 deletion.
  1. +1 −1 examples/kdbkey.pp
  2. +9 −0 lib/puppet/provider/kdbkey/ruby.rb
@@ -114,7 +114,7 @@
# (see '$> kdb info type' for other types)
kdbkey { 'spec/x1':
prefix => $ns_validation,
value => 7,
value => 11,
check => {
'range' => '0-10'
@@ -302,12 +302,21 @@ def check=(value)
# set meta data on spec_key
spec_to_set.each do |spec_name, spec_value|
spec_key[spec_name] = spec_value
# also add the check meta data to resource_key directly, they will get
# removed by the 'spec' plugin (it the bug is fixed ;)
# This is required, since the check is only evaluated if the key has the
# appropriate metadata attached. If the spec_key is created with the same
# keyset, the resources value will be set before the check can be performed
# so we end up with an invalid value for the setting.
@resource_key[spec_name] = spec_value
# remove all not specified meta keys from spec_key starting with 'check'
spec_key.meta.each do |e|
if "check" and !spec_to_set.include?
# perform same operation on resource_key

0 comments on commit bc4235d

Please sign in to comment.