]> review.fuel-infra Code Review - puppet-modules/puppetlabs-apt.git/commitdiff
Pull line.strip into key_list_lines
authorDavid Schmitt <david.schmitt@puppet.com>
Mon, 25 Sep 2017 09:16:17 +0000 (10:16 +0100)
committerDavid Schmitt <david.schmitt@puppet.com>
Mon, 25 Sep 2017 12:30:43 +0000 (13:30 +0100)
lib/puppet/provider/apt_key2/apt_key2.rb

index 531fb83b657a77cb2a60c71b0c90b06458694a46..8e145ae9aafa9ab027ac00f1eadb88ac227a1841 100644 (file)
@@ -24,7 +24,7 @@ class Puppet::Provider::AptKey2::AptKey2
       if r[:name].length != 40
         context.warning(r[:name], 'The name should be a full fingerprint (40 characters) to avoid collision attacks, see the README for details.')
         fingerprint = key_list_lines.select { |l| l.start_with?('fpr:') }
-                                    .map { |l| l.strip.split(':').last }
+                                    .map { |l| l.split(':').last }
                                     .find { |fp| fp.end_with? r[:name] }
         r[:name] = fingerprint if fingerprint
       end
@@ -34,7 +34,7 @@ class Puppet::Provider::AptKey2::AptKey2
   end
 
   def key_list_lines
-    `apt-key adv --list-keys --with-colons --fingerprint --fixed-list-mode 2>/dev/null`.each_line
+    `apt-key adv --list-keys --with-colons --fingerprint --fixed-list-mode 2>/dev/null`.each_line.map(&:strip)
   end
 
   def get(_context)
@@ -49,7 +49,6 @@ class Puppet::Provider::AptKey2::AptKey2
     # )
     # lines = result.stdout
     key_list_lines.map { |line|
-      line = line.strip
       if line.start_with?('pub')
         pub_line = line
       elsif line.start_with?('fpr')