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

James Turnbull james at lovedthanlost.net
Fri Jan 15 09:07:35 UTC 2010


The following commit has been merged in the upstream branch:
commit 8b669985427a0acc41b842ce89047592922fa760
Author: Jesse Wolfe <jes5199 at gmail.com>
Date:   Mon Nov 30 15:51:05 2009 -0800

    Fixing 2849 puppet changes sshkey alias every run if it is blank
    
    Puppet was mis-parsing sshkey aliases when the last alias is an empty
    string.
    This is due to the counter-intuitive behavior of Ruby's String#split.
    
    Signed-off-by: Jesse Wolfe <jes5199 at gmail.com>

diff --git a/lib/puppet/provider/sshkey/parsed.rb b/lib/puppet/provider/sshkey/parsed.rb
index 0dc791b..4673b57 100755
--- a/lib/puppet/provider/sshkey/parsed.rb
+++ b/lib/puppet/provider/sshkey/parsed.rb
@@ -19,11 +19,9 @@ Puppet::Type.type(:sshkey).provide(:parsed,
 
     record_line :parsed, :fields => %w{name type key},
         :post_parse => proc { |hash|
-            if hash[:name] =~ /,/
-                names = hash[:name].split(",")
-                hash[:name] = names.shift
-                hash[:alias] = names
-            end
+            names = hash[:name].split(",", -1)
+            hash[:name]  = names.shift
+            hash[:alias] = names
         },
         :pre_gen => proc { |hash|
             if hash[:alias]
diff --git a/spec/unit/provider/sshkey/parsed.rb b/spec/unit/provider/sshkey/parsed.rb
new file mode 100755
index 0000000..c97656f
--- /dev/null
+++ b/spec/unit/provider/sshkey/parsed.rb
@@ -0,0 +1,19 @@
+#!/usr/bin/env ruby
+
+require File.dirname(__FILE__) + '/../../../spec_helper'
+
+provider_class = Puppet::Type.type(:sshkey).provider(:parsed)
+
+describe provider_class do
+    before do
+        @sshkey_class = Puppet::Type.type(:sshkey)
+        @provider_class = @sshkey_class.provider(:parsed)
+    end
+
+    it "should not drop an empty alias" do 
+        line = 'test,alias, ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAzwHhxXvIrtfIwrudFqc8yQcIfMudrgpnuh1F3AV6d2BrLgu/yQE7W5UyJMUjfj427sQudRwKW45O0Jsnr33F4mUw+GIMlAAmp9g24/OcrTiB8ZUKIjoPy/cO4coxGi8/NECtRzpD/ZUPFh6OEpyOwJPMb7/EC2Az6Otw4StHdXUYw22zHazBcPFnv6zCgPx1hA7QlQDWTu4YcL0WmTYQCtMUb3FUqrcFtzGDD0ytosgwSd+JyN5vj5UwIABjnNOHPZ62EY1OFixnfqX/+dUwrFSs5tPgBF/KkC6R7tmbUfnBON6RrGEmu+ajOTOLy23qUZB4CQ53V7nyAWhzqSK+hw=='
+        parsed = @provider_class.parse_line(line)
+        parsed[:alias].should == ["alias",""]
+    end
+
+end

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list