[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, master, updated. debian/0.24.7-1-98-gf19c0e5
James Turnbull
james at lovedthanlost.net
Wed Apr 8 21:48:21 UTC 2009
The following commit has been merged in the master branch:
commit 61661b1c46fafeabf1bdbc4778762831d7178d91
Author: Luke Kanies <luke at madstop.com>
Date: Tue Mar 3 21:36:56 2009 -0600
Fixing #1991 - ldap booleans get converted to booleans
Signed-off-by: Luke Kanies <luke at madstop.com>
diff --git a/lib/puppet/indirector/node/ldap.rb b/lib/puppet/indirector/node/ldap.rb
index 759db3a..ab5d47b 100644
--- a/lib/puppet/indirector/node/ldap.rb
+++ b/lib/puppet/indirector/node/ldap.rb
@@ -103,6 +103,8 @@ class Puppet::Node::Ldap < Puppet::Indirector::Ldap
end
end
+ result[:parameters] = convert_parameters(result[:parameters])
+
result
end
@@ -143,6 +145,29 @@ class Puppet::Node::Ldap < Puppet::Indirector::Ldap
node.environment = information[:environment] if information[:environment]
end
+ def convert_parameters(parameters)
+ result = {}
+ parameters.each do |param, value|
+ if value.is_a?(Array)
+ result[param] = value.collect { |v| convert(v) }
+ else
+ result[param] = convert(value)
+ end
+ end
+ result
+ end
+
+ # Convert any values if necessary.
+ def convert(value)
+ case value
+ when Integer, Fixnum, Bignum; value
+ when "true"; true
+ when "false"; false
+ else
+ value
+ end
+ end
+
# Find information for our parent and merge it into the current info.
def find_and_merge_parent(parent, information)
unless parent_info = name2hash(parent)
diff --git a/spec/unit/indirector/node/ldap.rb b/spec/unit/indirector/node/ldap.rb
index ed8809e..d407796 100755
--- a/spec/unit/indirector/node/ldap.rb
+++ b/spec/unit/indirector/node/ldap.rb
@@ -91,6 +91,26 @@ describe Puppet::Node::Ldap do
@searcher.entry2hash(@entry)[:parameters]["foo"].should == "one"
end
+ it "should convert 'true' values to the boolean 'true'" do
+ @entry.stubs(:to_hash).returns({"one" => ["true"]})
+ @searcher.entry2hash(@entry)[:parameters]["one"].should == true
+ end
+
+ it "should convert 'false' values to the boolean 'false'" do
+ @entry.stubs(:to_hash).returns({"one" => ["false"]})
+ @searcher.entry2hash(@entry)[:parameters]["one"].should == false
+ end
+
+ it "should convert 'true' values to the boolean 'true' inside an array" do
+ @entry.stubs(:to_hash).returns({"one" => ["true", "other"]})
+ @searcher.entry2hash(@entry)[:parameters]["one"].should == [true, "other"]
+ end
+
+ it "should convert 'false' values to the boolean 'false' inside an array" do
+ @entry.stubs(:to_hash).returns({"one" => ["false", "other"]})
+ @searcher.entry2hash(@entry)[:parameters]["one"].should == [false, "other"]
+ end
+
it "should add the parent's name if present" do
@entry.stubs(:vals).with("parentnode").returns(%w{foo})
@searcher.entry2hash(@entry)[:parent].should == "foo"
--
Puppet packaging for Debian
More information about the Pkg-puppet-devel
mailing list