]> review.fuel-infra Code Review - puppet-modules/puppetlabs-apt.git/commitdiff
Merge pull request #287 from oc243/master
authorMorgan Haskel <morgan@puppetlabs.com>
Thu, 15 May 2014 17:45:46 +0000 (13:45 -0400)
committerMorgan Haskel <morgan@puppetlabs.com>
Thu, 15 May 2014 17:45:46 +0000 (13:45 -0400)
Implement fancy progress bars configuration.

README.md
manifests/init.pp
spec/acceptance/apt_spec.rb

index 9443cd561d6160c94a4c57bb548cda1341ddd927..cbaab7247232d8baac139ac76175972e0d456c96 100644 (file)
--- a/README.md
+++ b/README.md
@@ -54,7 +54,8 @@ The parameters for `apt` are not required in general and are predominantly for d
       purge_sources_list   => false,
       purge_sources_list_d => false,
       purge_preferences_d  => false,
-      update_timeout       => undef
+      update_timeout       => undef,
+      fancy_progress       => undef
     }
 
 Puppet will manage your system's `sources.list` file and `sources.list.d` directory but will do its best to respect existing content.
index 48b62d178a30056b83d4edbde6598397bfad4497..c32c5daca4b0cf753756f419a1a298e00e1dc2a4 100644 (file)
@@ -36,7 +36,8 @@ class apt(
   $purge_preferences_d  = false,
   $update_timeout       = undef,
   $update_tries         = undef,
-  $sources              = undef
+  $sources              = undef,
+  $fancy_progress       = undef
 ) {
 
   if $::osfamily != 'Debian' {
@@ -102,6 +103,24 @@ class apt(
     recurse => $purge_preferences_d,
   }
 
+  case $fancy_progress {
+    true: {
+      file { '99progressbar':
+        ensure  => present,
+        content => 'Dpkg::Progress-Fancy "1";',
+        path    => "${apt_conf_d}/99progressbar",
+      }
+    }
+    false: {
+      file { '99progressbar':
+        ensure  => absent,
+        path    => "${apt_conf_d}/99progressbar",
+      }
+    }
+    undef: {} # do nothing
+    default: { fail('Valid values for fancy_progress are true or false') }
+  }
+
   case $disable_keys {
     true: {
       file { '99unauth':
index 13f1d50536c036100fef5d28f75295ff16b3da28..60def0e1544cd6ff86bc982bd36f6e25dc8d5b3d 100644 (file)
@@ -271,6 +271,34 @@ describe 'apt class', :unless => UNSUPPORTED_PLATFORMS.include?(fact('osfamily')
     end
   end
 
+  context 'fancy_progress => true' do
+    it 'should work with no errors' do
+      pp = <<-EOS
+      class { 'apt': fancy_progress => true }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true)
+    end
+
+    describe file('/etc/apt/apt.conf.d/99progressbar') do
+      it { should be_file }
+      it { should contain 'Dpkg::Progress-Fancy "1";' }
+    end
+  end
+  context 'fancy_progress => false' do
+    it 'should work with no errors' do
+      pp = <<-EOS
+      class { 'apt': fancy_progress => false }
+      EOS
+
+      apply_manifest(pp, :catch_failures => true)
+    end
+
+    describe file('/etc/apt/apt.conf.d/99progressbar') do
+      it { should_not be_file }
+    end
+  end
+
   context 'reset' do
     it 'fixes the sources.list' do
       shell('cp /tmp/sources.list /etc/apt')