[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. puppet-0.24.5-rc3-1456-g2f0b1e5

Brice Figureau brice-puppet at daysofwonder.com
Tue Oct 27 17:05:49 UTC 2009


The following commit has been merged in the upstream branch:
commit bfba2cdf8787f1e7fa778bba1b74c03fc06634cd
Author: Brice Figureau <brice-puppet at daysofwonder.com>
Date:   Wed Sep 23 20:22:44 2009 +0200

    Fix #2672 - Make sure nodenames keep their underscores when used as classname
    
    The #2627 fix was modifying nodename in case of string nodename, but
    was removing '_'. Since underscores is a valid character in a class
    name, we now allow it.
    
    Signed-off-by: Brice Figureau <brice-puppet at daysofwonder.com>

diff --git a/lib/puppet/parser/ast/leaf.rb b/lib/puppet/parser/ast/leaf.rb
index 2f00ea7..153120a 100644
--- a/lib/puppet/parser/ast/leaf.rb
+++ b/lib/puppet/parser/ast/leaf.rb
@@ -102,7 +102,7 @@ class Puppet::Parser::AST
         end
 
         def to_classname
-            to_s.downcase.gsub(/[^-a-zA-Z0-9:.]/,'').sub(/^\.+/,'')
+            to_s.downcase.gsub(/[^-\w:.]/,'').sub(/^\.+/,'')
         end
 
         # implementing eql? and hash so that when an HostName is stored
diff --git a/spec/unit/parser/ast/leaf.rb b/spec/unit/parser/ast/leaf.rb
index 69b704a..e968150 100755
--- a/spec/unit/parser/ast/leaf.rb
+++ b/spec/unit/parser/ast/leaf.rb
@@ -195,6 +195,16 @@ describe Puppet::Parser::AST::HostName do
         host.to_classname.should == "klassname"
     end
 
+    it "should preserve '_' in to_classname with a string nodename" do
+        host = Puppet::Parser::AST::HostName.new( :value => "node_with_underscore")
+        host.to_classname.should == "node_with_underscore"
+    end
+
+    it "should preserve '_' in to_classname with a regex nodename" do
+        host = Puppet::Parser::AST::HostName.new( :value => Puppet::Parser::AST::Regex.new(:value => "/\dnode_with_underscore\.+/") )
+        host.to_classname.should == "dnode_with_underscore."
+    end
+
     it "should return a string usable as classname when calling to_classname" do
         host = Puppet::Parser::AST::HostName.new( :value => Puppet::Parser::AST::Regex.new(:value => "/^this-is not at a classname$/") )
         host.to_classname.should == "this-isnotaclassname"

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list