]> review.fuel-infra Code Review - puppet-modules/puppetlabs-apt.git/commitdiff
Merge pull request #672 from domcleal/architecture-fact
authorHunter Haugen <hunter@puppet.com>
Wed, 26 Apr 2017 18:30:11 +0000 (11:30 -0700)
committerGitHub <noreply@github.com>
Wed, 26 Apr 2017 18:30:11 +0000 (11:30 -0700)
Fix architecture fact overriding unset `architecture` source option

manifests/source.pp
spec/defines/source_spec.rb
templates/source.list.epp

index 8db3b28ef12457c501f498017372fe4cd6720458..9cb21338d771a87615ec9595a4548d21dcee458e 100644 (file)
@@ -99,13 +99,13 @@ define apt::source(
   $header = epp('apt/_header.epp')
 
   $sourcelist = epp('apt/source.list.epp', {
-    'comment'        => $comment,
-    'includes'       => $includes,
-    'architecture'   => $architecture,
-    'allow_unsigned' => $_allow_unsigned,
-    'location'       => $location,
-    'release'        => $_release,
-    'repos'          => $repos,
+    'comment'          => $comment,
+    'includes'         => $includes,
+    'opt_architecture' => $architecture,
+    'allow_unsigned'   => $_allow_unsigned,
+    'location'         => $location,
+    'release'          => $_release,
+    'repos'            => $repos,
   })
 
   apt::setting { "list-${name}":
index 0972512699d917132ac1d6e3d8c134e7c6b51120..10a8062911332167813a7eac0eec777c058b42db 100644 (file)
@@ -237,6 +237,30 @@ describe 'apt::source' do
     }
   end
 
+  context 'with architecture fact and unset architecture parameter' do
+    let :facts do
+      {
+        :architecture    => 'amd64',
+        :os => { :family => 'Debian', :name => 'Debian', :release => { :major => '7', :full => '7.0' }},
+        :lsbdistid       => 'Debian',
+        :lsbdistcodename => 'wheezy',
+        :osfamily        => 'Debian',
+        :puppetversion   => Puppet.version,
+      }
+    end
+    let :params do
+      {
+        :location => 'hello.there',
+        :include  => {'deb' => false, 'src' => true,},
+      }
+    end
+
+    it { is_expected.to contain_apt__setting('list-my_source').with({
+      :ensure => 'present',
+    }).with_content(/# my_source\ndeb-src hello.there wheezy main\n/)
+    }
+  end
+
   context 'include_src => true' do
     let :facts do
       {
index 727766c376cb092bfee570a6abdce7fa332e5ddc..4b29726c57464ca65f743d68b73d3b708ef2d4c4 100644 (file)
@@ -1,10 +1,10 @@
-<%- | String $comment, Hash $includes, $architecture, Boolean $allow_unsigned, $location, $release, String $repos | -%>
+<%- | String $comment, Hash $includes, $opt_architecture, Boolean $allow_unsigned, $location, $release, String $repos | -%>
 # <%= $comment %>
 <%- if $includes['deb'] { -%>
-deb <%- if ($architecture or $allow_unsigned) {-%>
- [<%- if ($architecture) {%>arch=<%= $architecture %><% } %><%if ($architecture and $allow_unsigned) {%> <% }%><% if ($allow_unsigned) {%>trusted=yes<% } %>] <%- } %> <%= $location %> <%= $release %> <%= $repos %>
+deb <%- if ($opt_architecture or $allow_unsigned) {-%>
+ [<%- if ($opt_architecture) {%>arch=<%= $opt_architecture %><% } %><%if ($opt_architecture and $allow_unsigned) {%> <% }%><% if ($allow_unsigned) {%>trusted=yes<% } %>] <%- } %> <%= $location %> <%= $release %> <%= $repos %>
 <%- } -%>
 <%- if $includes['src'] { -%>
-deb-src <%- if $architecture or $allow_unsigned { -%>
- [<%- if ($architecture) {%>arch=<%= $architecture %><% } %><%if ($architecture and $allow_unsigned) {%> <% }%><% if ($allow_unsigned) {%>trusted=yes<% } %>] <%- } %> <%= $location %> <%= $release %> <%= $repos %>
+deb-src <%- if $opt_architecture or $allow_unsigned { -%>
+ [<%- if ($opt_architecture) {%>arch=<%= $opt_architecture %><% } %><%if ($opt_architecture and $allow_unsigned) {%> <% }%><% if ($allow_unsigned) {%>trusted=yes<% } %>] <%- } %> <%= $location %> <%= $release %> <%= $repos %>
 <%- } -%>