]> review.fuel-infra Code Review - puppet-modules/puppetlabs-apt.git/commitdiff
(MODULES-3414) Limit non-strict parsing to pre-3.5.0 only
authorHunter Haugen <hunter@puppet.com>
Wed, 27 Jul 2016 04:23:12 +0000 (21:23 -0700)
committerHunter Haugen <hunter@puppet.com>
Wed, 27 Jul 2016 15:39:42 +0000 (08:39 -0700)
Puppet 3.5.0 introduced strict variables and the module handles strict
variables by using the defined() function. This does not work on prior
versions of puppet so we must gate based on that version.

Puppet 4 series has a new setting `strict` that may be set to enforce
strict variables while `strict_variables` remains unset (see PUP-6358)
which causes this conditional to erroniously use non-strict 3.5-era
parsing and fail.

The new conditional corrects the cases such that strict variable
behavior happens on versions 3.5.0 and later.

manifests/params.pp
spec/defines/key_compat_spec.rb
spec/defines/source_compat_spec.rb

index b75a0e7dcc9cf181ac19e09982b98547d32663c4..ea1087e7a93655e371cb99c1d039a0f64c5016ef 100644 (file)
@@ -4,9 +4,9 @@ class apt::params {
     fail('This module only works on Debian or derivatives like Ubuntu')
   }
 
-  # prior to puppet 3.5.0, defined couldn't test if a variable was defined
-  # strict variables wasn't added until 3.5.0, so this should be fine.
-  if ! $::settings::strict_variables {
+  # prior to puppet 3.5.0, defined() couldn't test if a variable was defined.
+  # strict_variables wasn't added until 3.5.0, so this should be fine.
+  if $::puppetversion and versioncmp($::puppetversion, '3.5.0') < 0 {
     $xfacts = {
       'lsbdistcodename'     => $::lsbdistcodename,
       'lsbdistrelease'      => $::lsbdistrelease,
index 2faee9e5345da1be8b3a4dc3356abca6c1bd3b54..7937c78db2121e6ab34486b1f3522f56576c9dc1 100644 (file)
@@ -4,6 +4,7 @@ describe 'apt::key', :type => :define do
   let(:facts) { {
     :lsbdistid => 'Debian',
     :osfamily => 'Debian',
+    :puppetversion => Puppet.version,
   } }
   GPG_KEY_ID = '47B320EB4C7C375AA9DAE1A01054B7A24BD6EC30'
 
index 0b98176e2a6923f177e38b0c79bdb4e7e8090014..11d6d3a3c3ce5bf7f5149c80da0ca8d63c59d888 100644 (file)
@@ -13,6 +13,7 @@ describe 'apt::source', :type => :define do
         :lsbdistid       => 'Debian',
         :lsbdistcodename => 'wheezy',
         :osfamily        => 'Debian',
+        :puppetversion   => Puppet.version,
       }
     end
 
@@ -34,6 +35,7 @@ describe 'apt::source', :type => :define do
         :lsbdistid       => 'Debian',
         :lsbdistcodename => 'wheezy',
         :osfamily        => 'Debian'
+        :puppetversion   => Puppet.version,
       }
     end
     let :params do
@@ -88,7 +90,8 @@ describe 'apt::source', :type => :define do
       {
         :lsbdistid       => 'Debian',
         :lsbdistcodename => 'wheezy',
-        :osfamily        => 'Debian'
+        :osfamily        => 'Debian',
+        :puppetversion   => Puppet.version,
       }
     end
     let :params do
@@ -107,7 +110,8 @@ describe 'apt::source', :type => :define do
       {
         :lsbdistid       => 'Debian',
         :lsbdistcodename => 'wheezy',
-        :osfamily        => 'Debian'
+        :osfamily        => 'Debian',
+        :puppetversion   => Puppet.version,
       }
     end
     let :params do
@@ -126,7 +130,8 @@ describe 'apt::source', :type => :define do
       {
         :lsbdistid       => 'Debian',
         :lsbdistcodename => 'wheezy',
-        :osfamily        => 'Debian'
+        :osfamily        => 'Debian',
+        :puppetversion   => Puppet.version,
       }
     end
     let :params do
@@ -146,7 +151,8 @@ describe 'apt::source', :type => :define do
       let :facts do
         {
           :lsbdistid       => 'Debian',
-          :osfamily        => 'Debian'
+          :osfamily        => 'Debian',
+          :puppetversion   => Puppet.version,
         }
       end